package com.bbx.taxi.client.Activity.Main;

import android.Manifest;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.Html;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewStub;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.baidu.location.BDLocation;
import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BaiduMap.OnMapStatusChangeListener;
import com.baidu.mapapi.map.BaiduMap.OnMarkerClickListener;
import com.baidu.mapapi.map.BitmapDescriptor;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.MapStatus;
import com.baidu.mapapi.map.MapStatusUpdate;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.Marker;
import com.baidu.mapapi.map.MarkerOptions;
import com.baidu.mapapi.map.MyLocationConfiguration;
import com.baidu.mapapi.map.MyLocationConfiguration.LocationMode;
import com.baidu.mapapi.map.MyLocationData;
import com.baidu.mapapi.map.OverlayOptions;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.search.core.PoiInfo;
import com.baidu.mapapi.search.core.SearchResult;
import com.baidu.mapapi.search.geocode.GeoCodeResult;
import com.baidu.mapapi.search.geocode.GeoCoder;
import com.baidu.mapapi.search.geocode.OnGetGeoCoderResultListener;
import com.baidu.mapapi.search.geocode.ReverseGeoCodeOption;
import com.baidu.mapapi.search.geocode.ReverseGeoCodeResult;
import com.baidu.mapapi.utils.DistanceUtil;
import com.bbx.androidapi.util.SharedPreUtil;
import com.bbx.androidapi.util.ToastUtil;
import com.bbx.api.gclient.GMsg;
import com.bbx.api.sdk.model.passanger.Return.ActivityContent;
import com.bbx.api.sdk.model.passanger.Return.CarType.CarData;
import com.bbx.api.sdk.model.passanger.Return.CarType.CarType;
import com.bbx.api.sdk.model.passanger.Return.CarType.NewCarType;
import com.bbx.api.sdk.model.passanger.Return.CarType.NewData;
import com.bbx.api.sdk.model.passanger.Return.Coupon.Coupons;
import com.bbx.api.sdk.model.passanger.Return.CouponCount;
import com.bbx.api.sdk.model.passanger.Return.GetNearbysPoints;
import com.bbx.api.sdk.model.passanger.Return.Info;
import com.bbx.api.sdk.model.passanger.Return.Jmsg.Msgs.Data;
import com.bbx.api.sdk.model.passanger.Return.LeadStopsGetNearbys;
import com.bbx.api.sdk.model.passanger.Return.LocationInfo;
import com.bbx.api.sdk.model.passanger.Return.MeteredFee;
import com.bbx.api.sdk.model.passanger.Return.MyOrderList.MyOrderList;
import com.bbx.api.sdk.model.passanger.Return.NearByDriver;
import com.bbx.api.sdk.model.passanger.Return.NearByDriver.DriverDetails;
import com.bbx.api.sdk.model.passanger.Return.OrderId;
import com.bbx.api.sdk.model.passanger.Return.Price;
import com.bbx.api.sdk.model.passanger.Return.PriceAll;
import com.bbx.api.sdk.model.passanger.Return.PriceAll.PriceAllDetail;
import com.bbx.api.sdk.model.passanger.Return.UsableSale;
import com.bbx.api.sdk.model.passanger.Return.User;
import com.bbx.api.sdk.net.base.JsonBuild;
import com.bbx.api.util.LogUtils;
import com.bbx.api.util.SharedPreEncryptUtil;
import com.bbx.taxi.client.Activity.Address.EditAddressActivity;
import com.bbx.taxi.client.Activity.Base.BaseBBXActivity;
import com.bbx.taxi.client.Activity.Base.BaseMapMainActivity;
import com.bbx.taxi.client.Activity.Base.MyBaiduMap;
import com.bbx.taxi.client.Activity.ContactPersonActivity;
import com.bbx.taxi.client.Activity.LeaveMessageActivity;
import com.bbx.taxi.client.Activity.Main.IMainContract.LastAddr;
import com.bbx.taxi.client.Activity.Main.IMainContract.RESETVIEW;
import com.bbx.taxi.client.Activity.Main.IMainContract.SHAREVIEW_TYPE;
import com.bbx.taxi.client.Activity.Main.IMainContract.SHAREVIEW_TYPE2;
import com.bbx.taxi.client.Activity.Menu.ClauseActivity;
import com.bbx.taxi.client.Activity.Menu.MessageActivity;
import com.bbx.taxi.client.Activity.Menu.MyOrderActivity;
import com.bbx.taxi.client.Activity.Menu.PersonalDataActivity;
import com.bbx.taxi.client.Activity.Menu.RecommenActivity;
import com.bbx.taxi.client.Activity.Menu.SetActivity;
import com.bbx.taxi.client.Activity.Menu.WalletActivity;
import com.bbx.taxi.client.Activity.Order.StartServiceActivity;
import com.bbx.taxi.client.Activity.UseCouponActivity;
import com.bbx.taxi.client.Activity.Wallet.CouponActivity;
import com.bbx.taxi.client.Activity.login.LoginActivity;
import com.bbx.taxi.client.Adapter.SlideAdapter;
import com.bbx.taxi.client.Bean.Attribute.MainAttribute;
import com.bbx.taxi.client.Bean.Attribute.MainAttribute.CjType;
import com.bbx.taxi.client.Bean.Attribute.MainAttribute.OnContentFillingListener;
import com.bbx.taxi.client.Bean.Extra.AddressMsg;
import com.bbx.taxi.client.Bean.Extra.ClauseMsg;
import com.bbx.taxi.client.Bean.Extra.ContactPersonMsg;
import com.bbx.taxi.client.Bean.Extra.MainMsg;
import com.bbx.taxi.client.Bean.Extra.OrderMsg;
import com.bbx.taxi.client.Bean.Extra.PersonalDataActivityMsg;
import com.bbx.taxi.client.Bean.Extra.ThanksFeeMsg;
import com.bbx.taxi.client.Bean.Extra.UseCouponMsg;
import com.bbx.taxi.client.Bean.Line.CitiesBean.AppCitysBean;
import com.bbx.taxi.client.Bean.Line.CitiesBean.AppCitysBean.ChildCitysBeanX.ToCitiesBean.ChildCitysBean;
import com.bbx.taxi.client.Bean.LogMsg;
import com.bbx.taxi.client.Bean.Message.ObserverListener;
import com.bbx.taxi.client.Bean.Message.Publisher;
import com.bbx.taxi.client.Bean.Value;
import com.bbx.taxi.client.Bean.Wallect;
import com.bbx.taxi.client.DB.LineDB;
import com.bbx.taxi.client.MyApplication;
import com.bbx.taxi.client.MyApplication.OnLocationResultListener;
import com.bbx.taxi.client.R;
import com.bbx.taxi.client.Service.LoginService;
import com.bbx.taxi.client.Service.TimeService;
import com.bbx.taxi.client.Service.TokenService;
import com.bbx.taxi.client.Task.MyCarTypeTask;
import com.bbx.taxi.client.Task.MyOrderTask;
import com.bbx.taxi.client.Task.MyOrderingTask;
import com.bbx.taxi.client.Task.MyOrderingTask.OnOrderingFinishListener;
import com.bbx.taxi.client.Task.MyPriceTask;
import com.bbx.taxi.client.Util.AppStarted;
import com.bbx.taxi.client.Util.BackgroundUtils;
import com.bbx.taxi.client.Util.ClickFilter;
import com.bbx.taxi.client.Util.CouponUtils;
import com.bbx.taxi.client.Util.DateFormat;
import com.bbx.taxi.client.Util.FastBlur.BlurBuilder;
import com.bbx.taxi.client.Util.FormatUtil;
import com.bbx.taxi.client.Util.HttpBitmap;
import com.bbx.taxi.client.Util.ImageLoad.ImageLoader;
import com.bbx.taxi.client.Util.ImageLoad.ImageLoader.CUT;
import com.bbx.taxi.client.Util.IsDataFail;
import com.bbx.taxi.client.Util.MeasureViewUtils;
import com.bbx.taxi.client.Util.RequestUtils;
import com.bbx.taxi.client.Util.StartOrderUtils;
import com.bbx.taxi.client.Util.Tel;
import com.bbx.taxi.client.Util.ToCity2;
import com.bbx.taxi.client.Util.VersionUtils;
import com.bbx.taxi.client.Util.ViewBitmap;
import com.bbx.taxi.client.Util.WakeLockUtil;
import com.bbx.taxi.client.Util.ZoomUtils;
import com.bbx.taxi.client.widget.Dailog.MessageDialog;
import com.bbx.taxi.client.widget.Dailog.MyAlertDailog;
import com.bbx.taxi.client.widget.Dailog.MyAlertDailog.onClickLeftListener;
import com.bbx.taxi.client.widget.Dailog.MyAlertDailog.onClickRightListener;
import com.bbx.taxi.client.widget.Dailog.MyAlertDailog.onClickSingleListener;
import com.bbx.taxi.client.widget.Dailog.MyCityNotOpenedDailog;
import com.bbx.taxi.client.widget.Dailog.MyLineNotDialog;
import com.bbx.taxi.client.widget.Dailog.MyLineNotDialog.OnLineClickLeftListener;
import com.bbx.taxi.client.widget.Dailog.MyLineNotDialog.OnLineClickRightListener;
import com.bbx.taxi.client.widget.Drag.AddFareDragLayout;
import com.bbx.taxi.client.widget.Drag.FareDetailDragLayout;
import com.bbx.taxi.client.widget.Drag.ThanksFeeDragLayout;
import com.bbx.taxi.client.widget.GBSlideBar.GBSlideBar;
import com.bbx.taxi.client.widget.GBSlideBar.GBSlideBarListener;
import com.bbx.taxi.client.widget.ScrollView.MyHorizontalScrollView;
import com.bbx.taxi.client.widget.ScrollView.MyHorizontalScrollView.ScrollViewListener;
import com.bbx.taxi.client.widget.StatusBar.StatusBar;
import com.bbx.taxi.client.widget.TabStrip.CategoryTabStrip.OnTabStripPageChangeListener;
import com.bbx.taxi.client.widget.WaveView.WaveView;
import com.bbx.taxi.client.widget.pop.CollecteAddressPop;
import com.bbx.taxi.client.widget.pop.CollecteAddressPop.OnAddressPoPViewStateListener;
import com.bbx.taxi.client.widget.pop.DatePicker2;
import com.example.Util.DensityUtil;
import com.tbruyelle.rxpermissions.RxPermissions;
import com.yanxuwen.pickerview.CustomPicker;

import net.simonvt.menudrawer.MenuDrawer;
import net.simonvt.menudrawer.MenuDrawer.OnDrawerStateChangeListener;
import net.simonvt.menudrawer.Position;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import rx.functions.Action1;

/**
 * @Path com.bbx.taxi.client.Activity.Main.MainActivity1.java
 * @Author 严旭文
 * @Date 2016-9-6 下午3:42:11
 * @Company 蓝海（福建）信息技术有限公司
 * @Description
 */
public class MainActivity extends BaseMapMainActivity implements
		OnClickListener, OnTabStripPageChangeListener,
		OnContentFillingListener,
		OnAddressPoPViewStateListener, OnLocationResultListener,
		OnOrderingFinishListener, ObserverListener,
		OnGetGeoCoderResultListener, ScrollViewListener,SensorEventListener,IMainContract.ViewMain {
	public final static int requestCode = 1;
	public final static int resultCode = 1;
	@Bind(R.id.title_bar)
	RelativeLayout title_bar;
	@Bind(R.id.iv_left)
	ImageView iv_left;
	@Bind(R.id.layout_left)
	RelativeLayout layout_left;
	@Bind(R.id.layout_gbslidebar)
	RelativeLayout layout_gbslidebar;
	@Bind(R.id.layout_content)
	RelativeLayout layout_content;
	@Bind(R.id.pop_background)
	View pop_background;
	@Bind(R.id.bg_transparent)
	View bg_transparent;
	@Bind(R.id.layout_main)
	RelativeLayout layout_main;
	@Bind(R.id.tv_title)
	TextView tv_title;
	@Bind(R.id.tv_left_title)
	TextView tv_left_title;
	MapView mMapView;
	@Bind(R.id.layout_confirm)
	RelativeLayout layout_confirm;
	@Bind(R.id.confirm)
	RelativeLayout confirm;
	@Bind(R.id.iv_right_sub)
	ImageView iv_right_sub;
	@Bind(R.id.tv_prompt)
	public TextView tv_prompt;
	@Bind(R.id.layout_prompt)
	public RelativeLayout layout_prompt;
	@Bind(R.id.iv_prompt_exit)
	ImageView iv_prompt_exit;
	@Bind(R.id.iv_new)
	ImageView iv_new;
	@Bind(R.id.iv_wallet_new)
	ImageView iv_wallet_new;
	/** 抽屉 */
	@Bind(R.id.tv_kftel)
	TextView tv_kftel;
	@Bind(R.id.tv_name)
	TextView tv_name;
	@Bind(R.id.tv_phone)
	TextView tv_phone;
	@Bind(R.id.tv_coupon_count)
	TextView tv_coupon_count;
	@Bind(R.id.tv_share)
	TextView tv_share;

	/** ----------地图-------------- */
	@Bind(R.id.tv_myposition)
	TextView tv_myposition;
	@Bind(R.id.layout_myposition)
	RelativeLayout layout_myposition;
	@Bind(R.id.icon_mapid)
	ImageView icon_mapid;
	@Bind(R.id.layout_nearcount)
	LinearLayout layout_nearcount;
	@Bind(R.id.tv_nearcount)
	TextView tv_nearcount;
	/** ---------费用详情------------- */
	View view_fare_detail;
	FareDetailDragLayout dragLayout;
	/**加价详情*/
	View view_add_fare;
	AddFareDragLayout add_dragLayout;
	/**感谢费提醒*/
	View view_thanks_fee;
	ThanksFeeDragLayout thanks_dragLayout;
	/** ---------------------- */
	public static MenuDrawer mMenuDrawer;
	public static Activity context;
	private MyApplication mApplication;
	private MainAttribute main;
	public IMainContract.Presenter mPresenter;
	private LineDB db_line;// 线路数据库
	/** 不加载价格，，刚登陆的时候不加载 */
	public static boolean isNoLoad = false;
	/** 线路加载完成 */
	public boolean isLoadFinish = false;
	// /////////////引导栏//////////////////
	public GBSlideBar gbSlideBar;
	private SlideAdapter mAdapter;
	/** 可用优惠劵 */
	public static List<Coupons> list_available = new ArrayList<Coupons>();
	DisplayMetrics dm;
	int mapwidth_center = 0;
	int mapBoundsWidth=0;
	int mapheight_center = 0;
	int mapBoundsHeight=0;
	int height_content_sn;
	int height_content_pc;
	int height_content_bc;
	int height_content_kj;
	int toptitle;
	int oldposition;
	public ImageLoader imageLoader;
	//传感器
	private  SensorManager mSensorManager;
    private  Sensor mAccelerometer;
    //方向
    float direction=0;
    double latitude;
    double longitude;
    long showtime;//开始显示时间
    long locationtime;//定位时间
	// //////////////////////////////
	protected void onCreate(Bundle savedInstanceState) {
		StatusBar.setTranslucentStatus(this, true);
		WakeLockUtil.setWifiNeverSleep(this);
		if (getIntent().getExtras() != null) {
			if (getIntent().getExtras().getInt(MainMsg.extra_quit) == MainMsg.INTENT_QUIT) {
				// 退出登录
				// finish();
			}
		}
		context = this;
		mApplication = MyApplication.getInstance();
		main = MainAttribute.getInstance();
		mPresenter = new MainPresenter(this, this);
		mPresenter.setNotifiExtras(getIntent());
		mMenuDrawer = MenuDrawer.attach(this, MenuDrawer.Type.OVERLAY,
				Position.START, MenuDrawer.MENU_DRAG_CONTENT);
		dm = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(dm);
		clearMapCenterHeight();
		mMenuDrawer.setMenuSize((int) (dm.widthPixels * 0.85));
		mMenuDrawer.setMenuView(R.layout.leftmenu);// 设置菜单视图
		mMenuDrawer.setContentView(R.layout.main1);
		mMenuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_NONE);
		// 去掉阴影
		mMenuDrawer.setDropShadowEnabled(false);
		mMenuDrawer
				.setOnDrawerStateChangeListener(new OnDrawerStateChangeListener() {
					@Override
					public void onDrawerStateChange(int oldState, int newState) {
					}

					@Override
					public void onDrawerSlide(float openRatio, int offsetPixels) {
						if (openRatio != 0) {
							bg_transparent.setVisibility(View.VISIBLE);
							double totle = 255 * 0.25;
							int bgAlpha = (int) (totle * openRatio);
							layout_main.getBackground().setAlpha(255 - bgAlpha);
							bg_transparent.getBackground().setAlpha(
									(int) (bgAlpha + (65 * openRatio)));
							// 完全打开
							if (openRatio == 1) {
								if (mApplication.getUid() != null
										&& !mApplication.equals("")
										&& mApplication.getToken() != null
										&& !mApplication.getToken().equals("")) {
								} else {
									startActivityLogin();
									mHandler.postDelayed(new Runnable() {
										@Override
										public void run() {
											mMenuDrawer.closeMenu();
										}
									}, 500);
								}
							}
						} else {
							bg_transparent.setVisibility(View.GONE);
						}

					}
				});
		ButterKnife.bind(this);
		super.onCreate(savedInstanceState);
		setTitle();
		layout_main.setBackgroundDrawable(new BitmapDrawable(BackgroundUtils
				.createBackground(this)));
		init();
		initSlideBar();
		initData();
	}

	@Override
	protected void onResume() {
		super.onResume();
		Publisher.getInstance().addOb(this);
		RequestUtils.requestCouponCount(this);
		RequestUtils.requesBalance(this);
		postDelayed_Near();
		startService(new Intent(context, TimeService.class));
		if (mApplication != null) {
			if (mApplication.isLogin()) {
				MyOrderingTask.getInstance(context)
						.setOnOrderingFinishListener(this);
			} else {
				showOrderListIng(View.GONE, "");
			}

		}
		mApplication.isFirstActivity = false;
		if (!Value.isActive) {
			// app 从后台唤醒，进入前台
			Value.isActive = true;
			MyApplication.getInstance().setIsStartUp(true);
			if (Value.isUnSDK) {
				if (mApplication.getUid() != null && !mApplication.equals("")
						&& mApplication.getToken() != null
						&& !mApplication.getToken().equals("")) {
				} else {
					startActivityLogin();
				}
			}
		}
		//注册传感器
//		mSensorManager.registerListener(this, mAccelerometer,SensorManager.SENSOR_DELAY_NORMAL);
		//启动定位
		mApplication.onStartLocation();
	}
	 protected void onPause() {
         super.onPause();
         //取消传感器
         mSensorManager.unregisterListener(this);
         //取消定位
         mApplication.onStopLocation();
     }
	@Override
	protected void onNewIntent(final Intent intent) {
		super.onNewIntent(intent);
		setIntent(intent);
		mPresenter.setNotifiExtras(intent);
		mMenuDrawer.closeMenu(false);
		new Handler().postDelayed(new Runnable() {

			@Override
			public void run() {
				if (gbSlideBar != null) {
					gbSlideBar.setCurrentItem(mPresenter.getViewId());
				}
				// 市内
				if (mPresenter.isCity()) {
					mPresenter
							.shareView(SHAREVIEW_TYPE.sn, SHAREVIEW_TYPE2.all);
				} else {
					if(mPresenter.isCJ()){
						showCjType();
					}
					mPresenter.shareView(SHAREVIEW_TYPE.share,
							SHAREVIEW_TYPE2.time);
					mPresenter.shareView(SHAREVIEW_TYPE.share,
							SHAREVIEW_TYPE2.name);
					mPresenter.shareView(SHAREVIEW_TYPE.share,
							SHAREVIEW_TYPE2.name2);
					mPresenter.setRecommend(true);
					mPresenter.setRecommend(false);
				}
			}
		}, 100);

	}

	@Override
	public void init() {
		//权限请求
		RxPermissions.getInstance(this)
				.request(Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.ACCESS_FINE_LOCATION
				,Manifest.permission.WRITE_EXTERNAL_STORAGE)
				.subscribe(new Action1<Boolean>() {
			@Override
			public void call(Boolean granted) {
				if (granted) { // Always true pre-M

				} else {
				}
			}
		});
		imageLoader = new ImageLoader(context);
		layout_content.setLayoutTransition(mPresenter.getLayoutTransition());
		showMap();
		showCJ();
		showKJ();
		showSN();
		mPresenter.getLastOrderType();
		switch(VersionUtils.getVersionType(context)){
		case bbx:
			tv_kftel.setText(Value.TEL_KF);
			break;
		case tianshang:
			tv_share.setVisibility(View.GONE);
			tv_kftel.setText(Value.TEL_TSX);
			break;
		}
		/**实例化传感器*/
		mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
	    mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
	}

	@Override
	public void initSlideBar() {
		gbSlideBar = (GBSlideBar) findViewById(R.id.gbslidebar);
		Resources resources = getResources();
		mAdapter = new SlideAdapter(this,resources, new int[] {
				R.drawable.btn_selector_sn, R.drawable.btn_selector_cj,
				R.drawable.btn_selector_kj });

		mAdapter.setTextColor(new int[] {
				getResources().getColor(R.color.btn_nor),
				getResources().getColor(R.color.btn_nor),
				getResources().getColor(R.color.btn_nor) });
		gbSlideBar.setAdapter(mAdapter);
		gbSlideBar.setPosition(mPresenter.getViewId());
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			showSN();
			oldposition = 0;
			break;
		case Value.VIEWID_PC:
			showCJ();
			oldposition = 1;
			break;
		case Value.VIEWID_KJ:
			showKJ();
			oldposition = 2;
			break;
		}
		showtime=DateFormat.getTime();
		onLocationShowAddress(lat,lng);
		gbSlideBar.setOnGbSlideBarListener(new GBSlideBarListener() {
			@Override
			public void onPositionSelected(final int position) {
				mPresenter.setViewId(position);
				if (oldposition == position)
					return;
				mHandler.removeCallbacks(showRunnable);
				clearMapCenterHeight();
				setMapCenterHeight();
				setTitleLeft();
				switch (position) {
				case Value.VIEWID_SN:
					new Handler().postDelayed(new Runnable() {
						@Override
						public void run() {
							if (position != Value.VIEWID_SN)
								return;
							showSN();
							if (!mPresenter.isNoEndNull()) {
								setStartPoint(!main.isStartSameLatLng());
							} else {
								mHandler.postDelayed(new Runnable() {

									@Override
									public void run() {
										onContentFilling();
									}
								}, 1000);
							}
							oldposition = position;
						}
					}, 200);
					break;
				case Value.VIEWID_PC:
					new Handler().postDelayed(new Runnable() {

						@Override
						public void run() {
							if (position != Value.VIEWID_PC)
								return;
							showCJ();
							// 从市内跳转过来，并且没有目的地
							if (oldposition == Value.VIEWID_SN
									&& !mPresenter.isNoEndNull()) {
								setStartPoint(!main.isStartSameLatLng());
							} else {
								// 从市内过来，并且信息填写不完整，推荐上车点被清除，则重新获取推荐上车点
								if (oldposition == Value.VIEWID_SN
										&& !mPresenter.isPriceInfo()) {
									requesTuiJian(main.getStartLatitude() + "",
											main.getStartLongitude() + "");
								} else {
									mHandler.postDelayed(new Runnable() {

										@Override
										public void run() {
											onContentFilling();
										}
									}, 1000);
								}
							}
							oldposition = position;
						}
					}, 200);
					break;
				case Value.VIEWID_KJ:
					new Handler().postDelayed(new Runnable() {

						@Override
						public void run() {
							if (position != Value.VIEWID_KJ)
								return;
							showKJ();
							// 从市内跳转过来，并且没有目的地
							if (oldposition == Value.VIEWID_SN
									&& !mPresenter.isNoEndNull()) {
								setStartPoint(!main.isStartSameLatLng());
							} else {
								// 从市内过来，并且信息填写不完整，推荐上车点被清除，则重新获取推荐上车点
								if (oldposition == Value.VIEWID_SN
										&& !mPresenter.isNoEndNull()) {
									requesTuiJian(main.getStartLatitude() + "",
											main.getStartLongitude() + "");
								} else {
									mHandler.postDelayed(new Runnable() {

										@Override
										public void run() {
											onContentFilling();
										}
									}, 1000);
								}

							}
							oldposition = position;
						}
					}, 200);
					break;
				}
			}
		});
	}

	@Override
	public void initData() {
		// 先判断之前是否定位过了
		if (mApplication.mLocation != null
				&& mApplication.mLocation.getCity() != null
				&& !mApplication.mLocation.getCity().equals("null")) {
//			mApplication.onStopLocation();
			LogUtils.e(LogMsg.LOCATION, "已经定位");
			mHandler.postDelayed(new Runnable() {
				@Override
				public void run() {
					onLocationResult(mApplication.mLocation);
				}
			}, 500);
		} else if (mApplication.mResult != null
				&& mApplication.mResult.getAddressDetail().city != null
				&& !mApplication.mResult.getAddressDetail().city.equals("null")) {
//			mApplication.onStopLocation();
			LogUtils.e(LogMsg.LOCATION, "已经定位");
			mHandler.postDelayed(new Runnable() {
				@Override
				public void run() {
					onLocationResult(mApplication.mResult);
				}
			}, 500);
		}

		db_line = new LineDB();
		mApplication.setOnLocationResultListener(this);
		main.setOnContentFillingListener(this);
//		RequestUtils.requestLine(context, false);
		RequestUtils.requestInfo(context);
		LoginService.SDKlogin = false;
		// // 判断Token
		startService(new Intent(context, TokenService.class));
		if (mApplication.isLogin()) {
			// 启动登陆Service
			startService(new Intent(this, LoginService.class));
		}
		// 登陆的时候，暂时先放在这
		if (Value.need_fetch_pic != null && !Value.need_fetch_pic.equals("")) {
			// 图片资源
			String url = Value.need_fetch_pic;
			HttpBitmap.getHttpBitmap(context, url);
		}
	}

	@Override
	public void initName() {
		// 抽屉左上角的名字
		String name = mApplication.user_name;
		if (name == null || name.equals("")) {
			tv_name.setText(context.getString(R.string.passenger));
		} else if (!name.equals(tv_name.getText().toString())) {
			tv_name.setText(name);
		}
		// 抽屉左上角的电话
		String phone = mApplication.user_phone;
		if (phone != null && !phone.equals("")) {
			if (!phone.equals(tv_phone.getText().toString())) {
				tv_phone.setText(FormatUtil.onFormatTelephone(phone));
			}
		} else {
			tv_phone.setText("");
		}
		// 市内城际快件的名字
		if (main.getTel() != null && !main.getTel().equals("")
				&& main.getName() != null) {
			mPresenter.shareView(SHAREVIEW_TYPE.all,
					IMainContract.SHAREVIEW_TYPE2.name);
		}

	}
    @Override
	public void resetView(final RESETVIEW reset) {
		// 清空价格跟优惠劵
		clearCouponInfo();

		clearMapCenterHeight();
		height_content_sn = 0;
		height_content_pc = 0;
		height_content_bc = 0;
		height_content_kj = 0;
		clearMarker(true);
		// showSnOrKjTime(false, true);
		hideContactInfo(true);
		hidePriceInfo(true);
		setConfirm(false);
		hidePriceDetail();
		int addtime = mPresenter.isContactInfo() ? 200 : 0;
		//如果是清空目的地，则要延迟下时间，避免跟showStartAndEnd冲突,因为showStartAndEnd是延迟1s后开始启动
		if(reset==RESETVIEW.end){
			addtime=500;
		}
		mHandler.postDelayed(new Runnable() {

			@Override
			public void run() {
				mPresenter.resetCenterPoint();
				switch(reset){
				case all:
					mPresenter.onStartLocation();
					break;
				case start:
					mPresenter.clearStart();
					break;
				case end:
					mPresenter.clearEnd();
					break;
				}
			
				setTitleLeft();
				setStartPoint(true);
			}
		}, mPresenter.isBC() ? (800 + addtime) : (600 + addtime));

	}

	TextView sn_label_yuyue;
	TextView sn_label_now;
	LinearLayout layout_sn_label;
	/** 时间 */
	TextView tv_sn_time;
	LinearLayout layout_sn_time;
	/** 地址 */
	TextView tv_sn_start_address;
	TextView tv_sn_end_address;
	RelativeLayout layout_sn_start_address;
	RelativeLayout layout_sn_end_address;
	/** 切换 */
	RelativeLayout layout_sn_convert;

	ImageView sn_iv_locate;
	/** 试图 */
	View view_sn;
	View view_sn_address;
	View view_sn_time;
	View view_sn_lable;
	LinearLayout sn_layout_info;
	// 滚动
	ScrollView sn_scrollview;

	@Override
	public void showSN() {
		clearMarker(false);
		if (Citytype != null) {
			showCityType(Citytype);
		}
		setAnchor();
		if (view_cj != null)
			view_cj.setVisibility(View.GONE);
		if (view_kj != null)
			view_kj.setVisibility(View.GONE);
		int delayMillis = 500;
		if (layout_confirm.getVisibility() != View.GONE) {
			setConfirm(false);
		}
		if (view_sn == null) {
			ViewStub stub_sn = (ViewStub) findViewById(R.id.stub_sn);
			view_sn = stub_sn.inflate();
			View v = view_sn;
			v.setVisibility(View.GONE);
			sn_layout_info = (LinearLayout) v.findViewById(R.id.layout_info);
			sn_layout_info.setLayoutTransition(mPresenter
					.getCurrencyLayoutTransition());
			sn_iv_locate = (ImageView) v.findViewById(R.id.iv_locate);
			sn_iv_locate.setOnClickListener(this);
			sn_scrollview = (ScrollView) v.findViewById(R.id.scrollview);
			// 地址
			if (view_sn_address == null) {
				ViewStub stub_address = (ViewStub) v
						.findViewById(R.id.stub_address);
				view_sn_address = stub_address.inflate();
				View v_add = view_sn_address;
				tv_sn_start_address = (TextView) v_add
						.findViewById(R.id.tv_start_address);
				tv_sn_start_address
						.addTextChangedListener(new startTextWatcher());
				tv_sn_end_address = (TextView) v_add
						.findViewById(R.id.tv_end_address);
				layout_sn_convert = (RelativeLayout) v_add
						.findViewById(R.id.layout_convert);
				layout_sn_convert.setVisibility(View.GONE);
				layout_sn_start_address = (RelativeLayout) v_add
						.findViewById(R.id.layout_start_address);
				layout_sn_end_address = ((RelativeLayout) v_add
						.findViewById(R.id.layout_end_address));
				layout_sn_start_address.setOnClickListener(MainActivity.this);
				layout_sn_end_address.setOnClickListener(MainActivity.this);
				layout_sn_convert.setOnClickListener(MainActivity.this);

			}
			// 标签
			if (view_sn_lable == null) {
				ViewStub stub_label = (ViewStub) v
						.findViewById(R.id.stub_label_time);
				view_sn_lable = stub_label.inflate();
				View v_label = view_sn_lable;
				sn_label_yuyue = (TextView) v_label
						.findViewById(R.id.lable_yuyue);
				sn_label_now = (TextView) v_label.findViewById(R.id.lable_now);
				layout_sn_label = (LinearLayout) v_label
						.findViewById(R.id.layout_label);
				sn_label_yuyue.setOnClickListener(MainActivity.this);
				sn_label_now.setOnClickListener(MainActivity.this);
			}
			// 时间
			if (view_sn_time == null) {
				ViewStub stub_time = (ViewStub) v.findViewById(R.id.stub_time);
				view_sn_time = stub_time.inflate();
				view_sn_time.setVisibility(View.GONE);
				layout_sn_time = (LinearLayout) view_sn_time
						.findViewById(R.id.layout_time);
				layout_sn_time.setOnClickListener(MainActivity.this);
				tv_sn_time = (TextView) view_sn_time.findViewById(R.id.tv_time);
			}
			mHandler.postDelayed(showRunnable, delayMillis);
		} else {
			mHandler.postDelayed(showRunnable, delayMillis);
			mHandler.postDelayed(new Runnable() {
				@Override
				public void run() {
					initPriceInfo();
				}
			}, delayMillis + 1000);
		}
	}

	TextView cj_label_pc;
	TextView cj_label_bc;
	TextView cj_label_sf;
	LinearLayout layout_cj_label;
	/** 时间 */
	TextView tv_cj_time;
	LinearLayout layout_cj_time;
	/** 地址 */
	TextView tv_cj_start_address;
	TextView tv_cj_end_address;
	RelativeLayout layout_cj_start_address;
	RelativeLayout layout_cj_end_address;
	/** 切换 */
	RelativeLayout layout_cj_convert;

	ImageView cj_iv_locate;
	/** 试图 */
	View view_cj;
	View view_cj_address;
	View view_cj_time;
	View view_cj_lable;
	LinearLayout cj_layout_info;
	// 滚动
	ScrollView cj_scrollview;

	@Override
	public void showCJ() {
		clearMarker(false);
		showCjType();
		setAnchor();
		if (layout_no_incity != null)
			layout_no_incity.setVisibility(View.GONE);
		if (layout_tel != null) {
			layout_tel.setVisibility(View.GONE);
			if (mWaveView != null)
				mWaveView.stop();
		}

		if (view_sn != null)
			view_sn.setVisibility(View.GONE);
		if (view_kj != null)
			view_kj.setVisibility(View.GONE);
		int delayMillis = 500;
		if (layout_confirm.getVisibility() != View.GONE) {
			setConfirm(false);
		}
		if (view_cj == null) {
			ViewStub stub_cj = (ViewStub) findViewById(R.id.stub_cj);
			view_cj = stub_cj.inflate();
			View v = view_cj;
			v.setVisibility(View.GONE);
			cj_layout_info = (LinearLayout) v.findViewById(R.id.layout_info);
			cj_layout_info.setLayoutTransition(mPresenter
					.getCurrencyLayoutTransition());
			cj_iv_locate = (ImageView) v.findViewById(R.id.iv_locate);
			cj_iv_locate.setOnClickListener(this);
			cj_scrollview = (ScrollView) v.findViewById(R.id.scrollview);
			// 地址
			if (view_cj_address == null) {
				ViewStub stub_address = (ViewStub) v
						.findViewById(R.id.stub_address);
				view_cj_address = stub_address.inflate();
				View v_add = view_cj_address;
				tv_cj_start_address = (TextView) v_add
						.findViewById(R.id.tv_start_address);
				tv_cj_start_address
						.addTextChangedListener(new startTextWatcher());
				tv_cj_end_address = (TextView) v_add
						.findViewById(R.id.tv_end_address);
				layout_cj_convert = (RelativeLayout) v_add
						.findViewById(R.id.layout_convert);
				// 设置地址的间距
				int paddingright = MeasureViewUtils
						.getMeasuredWidth(layout_cj_convert);
				layout_cj_start_address = (RelativeLayout) v_add
						.findViewById(R.id.layout_start_address);
				layout_cj_start_address.setPadding(0, 0, paddingright, 0);
				layout_cj_end_address = ((RelativeLayout) v_add
						.findViewById(R.id.layout_end_address));
				layout_cj_end_address.setPadding(0, 0, paddingright, 0);
				layout_cj_start_address.setOnClickListener(MainActivity.this);
				layout_cj_end_address.setOnClickListener(MainActivity.this);
				layout_cj_convert.setOnClickListener(MainActivity.this);

			}
			// 标签
			if (view_cj_lable == null) {
				ViewStub stub_label = (ViewStub) v
						.findViewById(R.id.stub_label_type);
				view_cj_lable = stub_label.inflate();
				View v_label = view_cj_lable;
				cj_label_pc = (TextView) v_label.findViewById(R.id.lable_pc);
				cj_label_bc = (TextView) v_label.findViewById(R.id.lable_bc);
				cj_label_sf = (TextView) v_label.findViewById(R.id.lable_sf);
				layout_cj_label = (LinearLayout) v_label
						.findViewById(R.id.layout_label);
				cj_label_pc.setOnClickListener(MainActivity.this);
				cj_label_bc.setOnClickListener(MainActivity.this);
				cj_label_sf.setOnClickListener(MainActivity.this);
			}
			// 时间
			if (view_cj_time == null) {
				ViewStub stub_time = (ViewStub) v.findViewById(R.id.stub_time);
				view_cj_time = stub_time.inflate();
				View v_time = view_cj_time;
				layout_cj_time = (LinearLayout) v_time
						.findViewById(R.id.layout_time);
				layout_cj_time.setOnClickListener(MainActivity.this);
				tv_cj_time = (TextView) v_time.findViewById(R.id.tv_time);
			}
			mHandler.postDelayed(showRunnable, delayMillis);
		} else {
			mHandler.postDelayed(showRunnable, delayMillis);
			mHandler.postDelayed(new Runnable() {
				@Override
				public void run() {
					initPriceInfo();
				}
			}, delayMillis + 1000);
		}
	}

	TextView kj_label_yuyue;
	TextView kj_label_now;
	LinearLayout layout_kj_label;
	/** 时间 */
	TextView tv_kj_time;
	LinearLayout layout_kj_time;
	/** 地址 */
	TextView tv_kj_start_address;
	TextView tv_kj_end_address;
	RelativeLayout layout_kj_start_address;
	RelativeLayout layout_kj_end_address;

	RelativeLayout layout_kj_end_parent;
	TextView tv_kj_end_person;
	TextView tv_kj_shou;
	/** 切换 */
	RelativeLayout layout_kj_convert;

	ImageView kj_iv_locate;
	/** 试图 */
	View view_kj;
	View view_kj_address;
	View view_kj_time;
	View view_kj_lable;
	LinearLayout kj_layout_info;
	// 滚动
	ScrollView kj_scrollview;

	@Override
	public void showKJ() {
		clearMarker(false);
		setAnchor();
		if (layout_no_incity != null)
			layout_no_incity.setVisibility(View.GONE);
		if (layout_tel != null) {
			layout_tel.setVisibility(View.GONE);
			if (mWaveView != null)
				mWaveView.stop();
		}
		if (view_cj != null)
			view_cj.setVisibility(View.GONE);
		if (view_sn != null)
			view_sn.setVisibility(View.GONE);
		int delayMillis = 500;
		if (layout_confirm.getVisibility() != View.GONE) {
			setConfirm(false);
		}
		if (view_kj == null) {
			ViewStub stub_kj = (ViewStub) findViewById(R.id.stub_kj);
			view_kj = stub_kj.inflate();
			View v = view_kj;
			v.setVisibility(View.GONE);
			kj_layout_info = (LinearLayout) v.findViewById(R.id.layout_info);
			kj_layout_info.setLayoutTransition(mPresenter
					.getCurrencyLayoutTransition());
			kj_iv_locate = (ImageView) v.findViewById(R.id.iv_locate);
			kj_iv_locate.setOnClickListener(this);
			kj_scrollview = (ScrollView) v.findViewById(R.id.scrollview);
			// 地址
			if (view_kj_address == null) {
				ViewStub stub_address = (ViewStub) v
						.findViewById(R.id.stub_address);
				view_kj_address = stub_address.inflate();
				View v_add = view_kj_address;
				tv_kj_start_address = (TextView) v_add
						.findViewById(R.id.tv_start_address);
				tv_kj_start_address.setHint(getString(R.string.hint_start_kj));
				tv_kj_start_address
						.addTextChangedListener(new startTextWatcher());
				tv_kj_end_address = (TextView) v_add
						.findViewById(R.id.tv_end_address);
				tv_kj_end_address.setHint(getString(R.string.hint_end_kj));
				layout_kj_end_parent = (RelativeLayout) v_add
						.findViewById(R.id.layout_end_parent);
				tv_kj_end_person = (TextView) v_add
						.findViewById(R.id.tv_end_person);
				tv_kj_shou = (TextView) v_add.findViewById(R.id.tv_shou);
				tv_kj_end_person.addTextChangedListener(new TextWatcher() {
					@Override
					public void onTextChanged(CharSequence arg0, int arg1,
							int arg2, int arg3) {
						String text = arg0 + "";
						if (text != null && !text.equals("")) {
							tv_kj_shou.setVisibility(View.VISIBLE);
						} else {
							tv_kj_shou.setVisibility(View.GONE);
						}
					}

					@Override
					public void beforeTextChanged(CharSequence arg0, int arg1,
							int arg2, int arg3) {
					}

					@Override
					public void afterTextChanged(Editable arg0) {
					}
				});
				layout_kj_end_parent.setVisibility(View.VISIBLE);
				layout_kj_convert = (RelativeLayout) v_add
						.findViewById(R.id.layout_convert);
				layout_kj_convert.setVisibility(View.GONE);
				layout_kj_start_address = (RelativeLayout) v_add
						.findViewById(R.id.layout_start_address);
				layout_kj_end_address = ((RelativeLayout) v_add
						.findViewById(R.id.layout_end_address));
				layout_kj_start_address.setOnClickListener(MainActivity.this);
				layout_kj_end_address.setOnClickListener(MainActivity.this);
				layout_kj_convert.setOnClickListener(MainActivity.this);
				layout_kj_end_parent.setOnClickListener(MainActivity.this);

			}
			// 标签
			if (view_kj_lable == null) {
				ViewStub stub_label = (ViewStub) v
						.findViewById(R.id.stub_label_time);
				view_kj_lable = stub_label.inflate();
				View v_label = view_kj_lable;
				kj_label_yuyue = (TextView) v_label
						.findViewById(R.id.lable_yuyue);
				kj_label_now = (TextView) v_label.findViewById(R.id.lable_now);
				layout_kj_label = (LinearLayout) v_label
						.findViewById(R.id.layout_label);
				kj_label_yuyue.setOnClickListener(MainActivity.this);
				kj_label_now.setOnClickListener(MainActivity.this);
			}
			// 时间
			if (view_kj_time == null) {
				ViewStub stub_time = (ViewStub) v.findViewById(R.id.stub_time);
				view_kj_time = stub_time.inflate();
				view_kj_time.setVisibility(View.GONE);
				layout_kj_time = (LinearLayout) view_kj_time
						.findViewById(R.id.layout_time);
				layout_kj_time.setOnClickListener(MainActivity.this);
				tv_kj_time = (TextView) view_kj_time.findViewById(R.id.tv_time);
			}

			mHandler.postDelayed(showRunnable, delayMillis);
		} else {
			mHandler.postDelayed(showRunnable, delayMillis);
			mHandler.postDelayed(new Runnable() {
				@Override
				public void run() {
					initPriceInfo();
				}
			}, delayMillis + 1000);
		}
	}

	Runnable showRunnable = new Runnable() {
		@Override
		public void run() {
			switch (mPresenter.getViewId()) {
			case Value.VIEWID_SN:
				if (view_sn != null){
					view_sn.setVisibility(View.VISIBLE);	
					if(mPresenter.isPriceInfo()){
						showPriceInfo();
					}
				}
				mHandler.postDelayed(new Runnable() {
					@Override
					public void run() {
						shareViewSN(true);
					}
				}, 600);
				break;
			case Value.VIEWID_PC:
				if (view_cj != null){
					view_cj.setVisibility(View.VISIBLE);
					if(mPresenter.isPriceInfo()){
						showPriceInfo();
					}
				}
				mHandler.postDelayed(new Runnable() {
					@Override
					public void run() {
						shareViewCJ(true);
					}
				}, 600);
				break;
			case Value.VIEWID_KJ:
				if (view_kj != null){
					view_kj.setVisibility(View.VISIBLE);
					if(mPresenter.isPriceInfo()){
						showPriceInfo();
					}
				}
				mHandler.postDelayed(new Runnable() {
					@Override
					public void run() {
						shareViewKJ(true);
					}
				}, 600);

				break;
			}
		}
	};

	public void setTitleLeft() {
		if (mPresenter.isPriceInfo()) {
			iv_left.setImageResource(R.drawable.btn_top_blank);
		} else {
			iv_left.setImageResource(R.drawable.btn_top_leftme);
		}
		setTitle();
	}

	@SuppressWarnings("deprecation")
	@Override
	public void showSnOrKjTime(boolean isShow, boolean all) {
		if (all) {
			// 市内
			if (layout_sn_label == null || view_sn_time == null)
				return;
			if (isShow) {
				layout_sn_label.setBackgroundDrawable(this.getResources()
						.getDrawable(R.drawable.label_bg_book));
				if (view_sn_time != null) {
					view_sn_time.setVisibility(View.VISIBLE);
					sn_label_now.setTextColor(getResources().getColor(
							R.color.black));
					sn_label_yuyue.setTextColor(getResources().getColor(
							R.color.blue));
					showStartAndEnd();
				}
			} else {
				layout_sn_label.setBackgroundDrawable(this.getResources()
						.getDrawable(R.drawable.label_bg_now));
				if (view_sn_time != null) {
					view_sn_time.setVisibility(View.GONE);
					sn_label_now.setTextColor(getResources().getColor(
							R.color.blue));
					sn_label_yuyue.setTextColor(getResources().getColor(
							R.color.black));
					// 设置时间为现在出发
					main.setTime(Value.now_time, mPresenter.isCity());
					if (mPresenter.isCity()) {
						mPresenter.shareView(SHAREVIEW_TYPE.sn,
								SHAREVIEW_TYPE2.time);
					} else {
						mPresenter.shareView(SHAREVIEW_TYPE.share,
								SHAREVIEW_TYPE2.time);
					}
				}
			}
			// 快件
			if (layout_kj_label == null || view_kj_time == null)
				return;
			if (isShow) {
				layout_kj_label.setBackgroundDrawable(this.getResources()
						.getDrawable(R.drawable.label_bg_book));
				if (view_kj_time != null) {
					view_kj_time.setVisibility(View.VISIBLE);
					kj_label_now.setTextColor(getResources().getColor(
							R.color.black));
					kj_label_yuyue.setTextColor(getResources().getColor(
							R.color.blue));
					showStartAndEnd();
				}
			} else {
				layout_kj_label.setBackgroundDrawable(this.getResources()
						.getDrawable(R.drawable.label_bg_now));
				if (view_kj_time != null) {
					view_kj_time.setVisibility(View.GONE);
					kj_label_now.setTextColor(getResources().getColor(
							R.color.blue));
					kj_label_yuyue.setTextColor(getResources().getColor(
							R.color.black));
					// 设置时间为现在出发
					main.setTime(Value.now_time, mPresenter.isCity());
					if (mPresenter.isCity()) {
						mPresenter.shareView(SHAREVIEW_TYPE.sn,
								SHAREVIEW_TYPE2.time);
					} else {
						mPresenter.shareView(SHAREVIEW_TYPE.share,
								SHAREVIEW_TYPE2.time);
					}
				}
			}
		} else {
			View layout_label = null;
			View view_time = null;
			TextView tv_label_now = null, tv_label_yuyue = null;
			switch (mPresenter.getViewId()) {
			case Value.VIEWID_SN:
				layout_label = layout_sn_label;
				view_time = view_sn_time;
				tv_label_now = sn_label_now;
				tv_label_yuyue = sn_label_yuyue;
				break;
			case Value.VIEWID_KJ:
				layout_label = layout_kj_label;
				view_time = view_kj_time;
				tv_label_now = kj_label_now;
				tv_label_yuyue = kj_label_yuyue;
				break;
			}
			if (layout_label == null || view_time == null)
				return;
			if (isShow) {
				layout_label.setBackgroundDrawable(this.getResources()
						.getDrawable(R.drawable.label_bg_book));
				if (view_time != null) {
					view_time.setVisibility(View.VISIBLE);
					tv_label_now.setTextColor(getResources().getColor(
							R.color.black));
					tv_label_yuyue.setTextColor(getResources().getColor(
							R.color.blue));
					showStartAndEnd();
				}
			} else {
				layout_label.setBackgroundDrawable(this.getResources()
						.getDrawable(R.drawable.label_bg_now));
				if (view_time != null) {
					view_time.setVisibility(View.GONE);
					tv_label_now.setTextColor(getResources().getColor(
							R.color.blue));
					tv_label_yuyue.setTextColor(getResources().getColor(
							R.color.black));
					// 设置时间为现在出发
					main.setTime(Value.now_time, mPresenter.isCity());
					setEnabled(false);
					if (mPresenter.isCity()) {
						mHandler.postDelayed(new Runnable() {

							@Override
							public void run() {
								mPresenter.shareView(SHAREVIEW_TYPE.sn,
										SHAREVIEW_TYPE2.time);
							}
						}, 800);

					} else {
						mHandler.postDelayed(new Runnable() {

							@Override
							public void run() {
								mPresenter.shareView(SHAREVIEW_TYPE.share,
										SHAREVIEW_TYPE2.time);
							}
						}, 800);

					}
				}
			}
		}
	}

	int down_y = 0;
	View view_sn_price_info;
	View view_cj_price_info;
	View view_kj_price_info;
	View view_price_info;
	/** 展开按钮 */
	ImageView sn_content_open;
	ImageView cj_content_open;
	ImageView kj_content_open;
	/** 展开按钮的间距 */
	View sn_open_padding;
	View cj_open_padding;
	View kj_open_padding;
	/** 优惠劵 */
	TextView tv_sn_coupon;
	TextView tv_cj_coupon;
	TextView tv_kj_coupon;
	/**优惠劵加载框*/
	ProgressBar pb_sn_coupon;
	ProgressBar pb_cj_coupon;
	ProgressBar pb_kj_coupon;
	/**价格请求加载框*/
	RelativeLayout layout_pb_sn_price;
	RelativeLayout layout_pb_cj_price;
	RelativeLayout layout_pb_kj_price;
	ProgressBar pb_sn_price;
	ProgressBar pb_cj_price;
	ProgressBar pb_kj_price;
	/** 价格 */
	TextView tv_sn_pay;
	TextView tv_cj_pay;
	TextView tv_kj_pay;
	/** 条款 */
	TextView tv_kj_clause;

	/** 感谢费 */
	RelativeLayout layout_thanks_fee;
	TextView tv_thanks_fee;
	/** 拼车或者包车数量 ，id跟感谢费一样 */
	TextView tv_car_count;

	/** 价格显示换成提示文字，市内为以计价器为准 */
	TextView tv_sn_remind;
	TextView tv_cj_remind;
	TextView tv_kj_remind;
	RelativeLayout layout_sn_remind;
	RelativeLayout layout_cj_remind;
	RelativeLayout layout_kj_remind;
	/** 价格整块的布局 */
	RelativeLayout layout_sn_pay;
	RelativeLayout layout_cj_pay;
	RelativeLayout layout_kj_pay;
	/** 价格信息 */
	RelativeLayout layout_sn_price;
	RelativeLayout layout_cj_price;
	RelativeLayout layout_kj_price;
    
	MyHorizontalScrollView cj_horizontalScrollView;
	MyHorizontalScrollView sn_horizontalScrollView;
	/** 汽车类型 1是的父类MyHorizontalScrollView是可以滚动的，也就是说数量大于3
	 *        2是不可以滚动的，数量小于3*/
	LinearLayout sn_layout_scroll,cj_layout_scroll,sn_layout_scroll2, cj_layout_scroll2;
	/**汽车类型的左右控件*/
	ImageView sn_iv_more_left,cj_iv_more_left,sn_iv_more_right,cj_iv_more_right;
	RelativeLayout sn_layout_cartype,cj_layout_cartype;
	/** 日租类型 */
	RelativeLayout sn_layout_rent,cj_layout_rent;
	Button sn_btn_rent_1,cj_btn_rent_1, sn_btn_rent_2,cj_btn_rent_2, sn_btn_rent_3,cj_btn_rent_3;
	/**立减活动提示*/
	TextView sn_tv_usablesale,cj_tv_usablesale,kj_tv_usablesale;
	/**倍数或者打折*/
	TextView sn_iv_base_discount,cj_iv_base_discount,kj_iv_base_discount;

	@Override
	public void initPriceInfo() {
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			// 市内的价格信息
			if (view_sn_price_info == null) {
				ViewStub stub_price_info = (ViewStub) view_sn
						.findViewById(R.id.stub_price_info);
				view_sn_price_info = stub_price_info.inflate();
				final View v = view_sn_price_info;
				view_price_info = v;
				((LinearLayout) v).setLayoutTransition(mPresenter
						.getCurrencyLayoutTransition());
				v.setVisibility(View.GONE);
				sn_content_open = (ImageView) v
						.findViewById(R.id.iv_content_open);
				sn_open_padding = (View) v.findViewById(R.id.open_padding);
				tv_thanks_fee = (TextView) v.findViewById(R.id.tv_thanks_fee);
				switch(VersionUtils.getVersionType(context)){
				case bbx:
					tv_thanks_fee.setText(getString(R.string.schedule_fee));
					break;
				case tianshang:
					tv_thanks_fee.setText(getString(R.string.schedule_fee2));
					break;
				}
				tv_sn_remind = (TextView) v.findViewById(R.id.tv_remind);
				layout_sn_remind=(RelativeLayout)v.findViewById(R.id.layout_remind);
				layout_sn_pay = (RelativeLayout) v
						.findViewById(R.id.stub_price);
				layout_sn_pay.setVisibility(View.INVISIBLE);
				tv_sn_coupon = (TextView) v.findViewById(R.id.tv_coupon);
				pb_sn_coupon=(ProgressBar)v.findViewById(R.id.progress_coupon);
				pb_sn_price=(ProgressBar)v.findViewById(R.id.progress_price);
				layout_pb_sn_price=(RelativeLayout)v.findViewById(R.id.layout_progress_price);
				tv_sn_pay = (TextView) v.findViewById(R.id.tv_pay);
				layout_sn_price = (RelativeLayout) v
						.findViewById(R.id.layout_price);
				//车型跟日租
				sn_horizontalScrollView=(MyHorizontalScrollView) v
						.findViewById(R.id.horizontalscrollview);
				sn_layout_scroll = (LinearLayout) v
						.findViewById(R.id.layout_scroll);
				sn_layout_scroll2 = (LinearLayout) v
						.findViewById(R.id.layout_scroll2);
				sn_iv_more_left=(ImageView)v.findViewById(R.id.iv_more_left);
				sn_iv_more_right=(ImageView)v.findViewById(R.id.iv_more_right);
				sn_layout_cartype = (RelativeLayout) v
						.findViewById(R.id.layout_cartype);
				sn_layout_rent = (RelativeLayout) v
						.findViewById(R.id.layout_rent);
				sn_btn_rent_1 = (Button) v.findViewById(R.id.btn_rent_1);
				sn_btn_rent_2 = (Button) v.findViewById(R.id.btn_rent_2);
				sn_btn_rent_3 = (Button) v.findViewById(R.id.btn_rent_3);
				list_sn_rent_btn = new Button[] { sn_btn_rent_1, sn_btn_rent_2,
						sn_btn_rent_3 };
				sn_btn_rent_1.setOnClickListener(this);
				sn_btn_rent_2.setOnClickListener(this);
				sn_btn_rent_3.setOnClickListener(this);
				layout_sn_price.setOnClickListener(this);
				sn_content_open.setOnClickListener(this);
				tv_thanks_fee.setOnClickListener(this);
				tv_sn_coupon.setOnClickListener(this);
				sn_tv_usablesale=(TextView) v.findViewById(R.id.tv_usablesale);
				sn_iv_base_discount=(TextView) v.findViewById(R.id.iv_base_discount);
			}
			break;
		case Value.VIEWID_PC:
		case Value.VIEWID_KJ:
			if (view_cj_price_info == null) {
				ViewStub stub_price_info = (ViewStub) view_cj
						.findViewById(R.id.stub_price_info);
				view_cj_price_info = stub_price_info.inflate();
				final View v = view_cj_price_info;
				view_price_info = v;
				((LinearLayout) v).setLayoutTransition(mPresenter
						.getCurrencyLayoutTransition());
				v.setVisibility(View.GONE);
				cj_content_open = (ImageView) v
						.findViewById(R.id.iv_content_open);
				cj_open_padding = (View) v.findViewById(R.id.open_padding);
				tv_car_count = (TextView) v.findViewById(R.id.tv_thanks_fee);
				tv_cj_remind = (TextView) v.findViewById(R.id.tv_remind);
				layout_cj_remind=(RelativeLayout)v.findViewById(R.id.layout_remind);
				layout_cj_pay = (RelativeLayout) v
						.findViewById(R.id.stub_price);
				tv_cj_coupon = (TextView) v.findViewById(R.id.tv_coupon);
				pb_cj_coupon=(ProgressBar)v.findViewById(R.id.progress_coupon);
				pb_cj_price=(ProgressBar)v.findViewById(R.id.progress_price);
				layout_pb_cj_price=(RelativeLayout)v.findViewById(R.id.layout_progress_price);
				tv_cj_pay = (TextView) v.findViewById(R.id.tv_pay);
				//车型跟日租
				cj_horizontalScrollView=(MyHorizontalScrollView) v
						.findViewById(R.id.horizontalscrollview);
				cj_layout_scroll = (LinearLayout) v
						.findViewById(R.id.layout_scroll);
				cj_layout_scroll2 = (LinearLayout) v
						.findViewById(R.id.layout_scroll2);
				cj_iv_more_left=(ImageView)v.findViewById(R.id.iv_more_left);
				cj_iv_more_right=(ImageView)v.findViewById(R.id.iv_more_right);
				cj_layout_cartype = (RelativeLayout) v
						.findViewById(R.id.layout_cartype);
				cj_layout_rent = (RelativeLayout) v
						.findViewById(R.id.layout_rent);
				cj_btn_rent_1 = (Button) v.findViewById(R.id.btn_rent_1);
				cj_btn_rent_2 = (Button) v.findViewById(R.id.btn_rent_2);
				cj_btn_rent_3 = (Button) v.findViewById(R.id.btn_rent_3);
				list_cj_rent_btn = new Button[] { cj_btn_rent_1, cj_btn_rent_2,
						cj_btn_rent_3 };
				cj_btn_rent_1.setOnClickListener(this);
				cj_btn_rent_2.setOnClickListener(this);
				cj_btn_rent_3.setOnClickListener(this);
				cj_content_open.setOnClickListener(this);
				tv_car_count.setOnClickListener(this);
				tv_cj_coupon.setOnClickListener(this);
				layout_cj_price = (RelativeLayout) v
						.findViewById(R.id.layout_price);
				layout_cj_price.setOnClickListener(this);
				cj_tv_usablesale=(TextView) v.findViewById(R.id.tv_usablesale);
				cj_iv_base_discount=(TextView) v.findViewById(R.id.iv_base_discount);
				showCjType();
			}
			if (view_kj_price_info == null) {
				ViewStub stub_price_info = (ViewStub) view_kj
						.findViewById(R.id.stub_price_info);
				view_kj_price_info = stub_price_info.inflate();
				final View v = view_kj_price_info;
				view_price_info = v;
				((LinearLayout) v).setLayoutTransition(mPresenter
						.getCurrencyLayoutTransition());
				v.setVisibility(View.GONE);
				kj_content_open = (ImageView) v
						.findViewById(R.id.iv_content_open);
				kj_open_padding = (View) v.findViewById(R.id.open_padding);
				layout_thanks_fee = (RelativeLayout) v
						.findViewById(R.id.layout_thanks_fee);
				layout_thanks_fee.setVisibility(View.GONE);
				tv_kj_remind = (TextView) v.findViewById(R.id.tv_remind);
				layout_kj_remind=(RelativeLayout)v.findViewById(R.id.layout_remind);
				layout_kj_pay = (RelativeLayout) v
						.findViewById(R.id.stub_price);
				tv_kj_coupon = (TextView) v.findViewById(R.id.tv_coupon);
				tv_kj_coupon.setPadding(0, 0, 0, 0);
				pb_kj_coupon=(ProgressBar)v.findViewById(R.id.progress_coupon);
				pb_kj_price=(ProgressBar)v.findViewById(R.id.progress_price);
				layout_pb_kj_price=(RelativeLayout)v.findViewById(R.id.layout_progress_price);
				tv_kj_pay = (TextView) v.findViewById(R.id.tv_pay);
				tv_kj_clause = (TextView) v.findViewById(R.id.tv_clause);
				tv_kj_clause.setVisibility(View.VISIBLE);
				tv_kj_clause.setOnClickListener(this);
				kj_content_open.setOnClickListener(this);
				tv_kj_coupon.setOnClickListener(this);
				layout_kj_price = (RelativeLayout) v
						.findViewById(R.id.layout_price);
				layout_kj_price.setOnClickListener(this);
				kj_tv_usablesale=(TextView) v.findViewById(R.id.tv_usablesale);
				kj_iv_base_discount=(TextView) v.findViewById(R.id.iv_base_discount);
			}
			break;
		}

	}

	@Override
	public void showPriceInfo() {
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			// 市内的价格信息
			if (view_sn_price_info != null) {
				if (view_sn_price_info.getVisibility() != View.VISIBLE) {
					view_sn_price_info.setVisibility(View.VISIBLE);
					setConfirm(true);
					setThanks_fee();
				} else {
					setConfirm(true);
					setThanks_fee();
					return;
				}
			} else {
				initPriceInfo();
				showPriceInfo();
			}
			break;
		case Value.VIEWID_PC:// 拼车的价格信息
			if(!Value.isChengDu()&&main.getCount()>4){
				main.setCount(4);
				if(tv_car_count!=null)
				tv_car_count.setText(Html.fromHtml(String
						.format(context
								.getString(R.string.num),
								"<font color=\"#ff0000\">"
										+ main.getCount()
										+ "</font>")));
			}
			if (view_cj_price_info != null) {
				if (view_cj_price_info.getVisibility() != View.VISIBLE) {
					view_cj_price_info.setVisibility(View.VISIBLE);
					setConfirm(true);
				} else {
					setConfirm(true);
					return;
				}
			} else {
				initPriceInfo();
				showPriceInfo();
			}
			break;
		case Value.VIEWID_KJ:
			if (view_kj_price_info != null) {
				if (view_kj_price_info.getVisibility() != View.VISIBLE) {
					view_kj_price_info.setVisibility(View.VISIBLE);
					setConfirm(true);
				} else {
					setConfirm(true);
					return;
				}
			} else {
				initPriceInfo();
				showPriceInfo();
			}
			break;
		}
		// 获取费用详情
		if (view_fare_detail == null) {
			ViewStub stub_fare_detail = (ViewStub) findViewById(R.id.stub_fare_detail);
			view_fare_detail = stub_fare_detail.inflate();
			dragLayout = (FareDetailDragLayout) view_fare_detail
					.findViewById(R.id.dragLayout);

		}
		//加价详情
		if(view_add_fare==null){
			ViewStub stub_add_fare = (ViewStub) findViewById(R.id.stub_add_fare);
			view_add_fare = stub_add_fare.inflate();
			add_dragLayout = (AddFareDragLayout) view_add_fare
					.findViewById(R.id.add_dragLayout);

		}
		//感谢费提醒
		if(view_thanks_fee==null){
			ViewStub stub_thanks_fee = (ViewStub) findViewById(R.id.stub_thanks_fee);
			view_thanks_fee = stub_thanks_fee.inflate();
			thanks_dragLayout = (ThanksFeeDragLayout) view_thanks_fee
					.findViewById(R.id.thanks_dragLayout);
		}
		setTitleLeft();
		fullScroll();
		setHandler(MainPresenter.DIALOG_DISMISS);
	}

	public void hidePriceInfo(boolean all) {
		if (all) {
			if (view_sn_price_info != null
					&& view_sn_price_info.getVisibility() == View.VISIBLE) {
				view_sn_price_info.setVisibility(View.GONE);
			}
			if (view_cj_price_info != null
					&& view_cj_price_info.getVisibility() == View.VISIBLE) {
				view_cj_price_info.setVisibility(View.GONE);
				// 隐藏车型
				if (cj_layout_cartype != null) {
					cj_layout_cartype.setVisibility(View.GONE);
				}
				if (cj_layout_rent != null) {
					cj_layout_rent.setVisibility(View.GONE);
				}
			}
			if (view_kj_price_info != null
					&& view_kj_price_info.getVisibility() == View.VISIBLE) {
				view_kj_price_info.setVisibility(View.GONE);
			}
		} else {
			View view_price_info = null;
			switch (mPresenter.getViewId()) {
			case Value.VIEWID_SN:
				view_price_info = view_sn_price_info;
				break;
			case Value.VIEWID_PC:
				view_price_info = view_cj_price_info;
				// 隐藏车型
				if (cj_layout_cartype != null) {
					cj_layout_cartype.setVisibility(View.GONE);
				}
				if (cj_layout_rent != null) {
					cj_layout_rent.setVisibility(View.GONE);
				}
				break;
			case Value.VIEWID_KJ:
				view_price_info = view_kj_price_info;
				break;
			}
			if (view_price_info != null
					&& view_price_info.getVisibility() == View.VISIBLE) {
				view_price_info.setVisibility(View.GONE);
			}
		}
		setConfirm(false);
	}

	View view_sn_contact_info;
	View view_cj_contact_info;
	View view_kj_contact_info;
	/** 联系人 */
	TextView tv_sn_telephone;
	TextView tv_cj_telephone;
	TextView tv_kj_telephone;
	/** 留言 */
	TextView tv_sn_message;
	TextView tv_cj_message;
	TextView tv_kj_message;

	boolean isOpen=false;
	ImageView content_open;
	@Override
	public void showContactInfo() {
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			// 市内的联系人信息
			if (view_sn_contact_info == null) {
				ViewStub stub_contact_info = (ViewStub) view_sn
						.findViewById(R.id.stub_contact_info);
				view_sn_contact_info = stub_contact_info.inflate();
				tv_sn_telephone = (TextView) view_sn_contact_info
						.findViewById(R.id.tv_telephone);
				tv_sn_telephone.setOnClickListener(this);
				tv_sn_message = (TextView) view_sn_contact_info
						.findViewById(R.id.tv_leave_message);
				tv_sn_message.setVisibility(View.GONE);
				view_sn_contact_info.setVisibility(View.VISIBLE);
				sn_open_padding.setVisibility(View.GONE);
				mPresenter.shareView(SHAREVIEW_TYPE.sn, SHAREVIEW_TYPE2.name,
						false);
				mPresenter.setContactInfo(true);
				isOpen=true;
			} else {
				// 隐藏
				if (view_sn_contact_info.getVisibility() == View.VISIBLE) {
					view_sn_contact_info.setVisibility(View.GONE);
					sn_open_padding.setVisibility(View.VISIBLE);
					mPresenter.setContactInfo(false);
					isOpen=false;
				}
				// 显示
				else {
					view_sn_contact_info.setVisibility(View.VISIBLE);
					sn_open_padding.setVisibility(View.GONE);
					mPresenter.setContactInfo(true);
					fullScroll();
					isOpen=true;
				}

			}
			content_open=sn_content_open;
			break;
		case Value.VIEWID_PC:
			// 城际的联系人信息
			if (view_cj_contact_info == null) {
				ViewStub stub_contact_info = (ViewStub) view_cj
						.findViewById(R.id.stub_contact_info);
				view_cj_contact_info = stub_contact_info.inflate();
				tv_cj_telephone = (TextView) view_cj_contact_info
						.findViewById(R.id.tv_telephone);
				tv_cj_telephone.setOnClickListener(this);
				tv_cj_message = (TextView) view_cj_contact_info
						.findViewById(R.id.tv_leave_message);
				tv_cj_message.setOnClickListener(this);
				view_cj_contact_info.setVisibility(View.VISIBLE);
				cj_open_padding.setVisibility(View.GONE);
				mPresenter.shareView(SHAREVIEW_TYPE.pc, SHAREVIEW_TYPE2.name,
						false);
				mPresenter.setContactInfo(true);
				fullScroll();
				isOpen=true;
			} else {
				// 隐藏
				if (view_cj_contact_info.getVisibility() == View.VISIBLE) {
					view_cj_contact_info.setVisibility(View.GONE);
					cj_open_padding.setVisibility(View.VISIBLE);
					mPresenter.setContactInfo(false);
					isOpen=false;
				}
				// 显示
				else {
					view_cj_contact_info.setVisibility(View.VISIBLE);
					cj_open_padding.setVisibility(View.GONE);
					mPresenter.setContactInfo(true);
					fullScroll();
					isOpen=true;
				}

			}
			content_open=cj_content_open;
			break;
		case Value.VIEWID_KJ:
			// 快件的联系人信息
			if (view_kj_contact_info == null) {
				ViewStub stub_contact_info = (ViewStub) view_kj
						.findViewById(R.id.stub_contact_info);
				view_kj_contact_info = stub_contact_info.inflate();
				tv_kj_telephone = (TextView) view_kj_contact_info
						.findViewById(R.id.tv_telephone);
				tv_kj_telephone.setOnClickListener(this);
				tv_kj_message = (TextView) view_kj_contact_info
						.findViewById(R.id.tv_leave_message);
				tv_kj_message.setOnClickListener(this);
				view_kj_contact_info.setVisibility(View.VISIBLE);
				kj_open_padding.setVisibility(View.GONE);
				mPresenter.shareView(SHAREVIEW_TYPE.kj, SHAREVIEW_TYPE2.name,
						false);
				mPresenter.setContactInfo(true);
				fullScroll();
				isOpen=true;
			} else {
				// 隐藏
				if (view_kj_contact_info.getVisibility() == View.VISIBLE) {
					view_kj_contact_info.setVisibility(View.GONE);
					kj_open_padding.setVisibility(View.VISIBLE);
					mPresenter.setContactInfo(false);
					isOpen=false;
				}
				// 显示
				else {
					view_kj_contact_info.setVisibility(View.VISIBLE);
					kj_open_padding.setVisibility(View.GONE);
					mPresenter.setContactInfo(true);
					fullScroll();
					isOpen=true;
				}

			}
			content_open=kj_content_open;
			break;
		}
		ObjectAnimator animator = ObjectAnimator.ofFloat(content_open, "rotation", isOpen?0f:180f, isOpen?180f:360f);  
		animator.setDuration(300);  
		animator.start();    
		
	}

	@Override
	public void hideContactInfo(boolean all) {
		if (all) {
			mPresenter.setContactInfoAll(false);
			if (view_sn_contact_info != null
					&& view_sn_contact_info.getVisibility() == View.VISIBLE) {
				view_sn_contact_info.setVisibility(View.GONE);
				sn_open_padding.setVisibility(View.VISIBLE);
				ObjectAnimator animator_sn = ObjectAnimator.ofFloat(sn_content_open, "rotation", 0,0); 
				animator_sn.setDuration(0);  
				animator_sn.start(); 
			}
			if (view_cj_contact_info != null
					&& view_cj_contact_info.getVisibility() == View.VISIBLE) {

				view_cj_contact_info.setVisibility(View.GONE);
				cj_open_padding.setVisibility(View.VISIBLE);
				ObjectAnimator animator_cj = ObjectAnimator.ofFloat(cj_content_open, "rotation", 0,0); 
				animator_cj.setDuration(0);  
				animator_cj.start();

			}
			if (view_kj_contact_info != null
					&& view_kj_contact_info.getVisibility() == View.VISIBLE) {
				view_kj_contact_info.setVisibility(View.GONE);
				kj_open_padding.setVisibility(View.VISIBLE);
				ObjectAnimator animator_cj = ObjectAnimator.ofFloat(kj_content_open, "rotation", 0,0); 
				animator_cj.setDuration(0);  
				animator_cj.start();

			}
		} else {
			View view_contact_info = null;
			switch (mPresenter.getViewId()) {
			case Value.VIEWID_SN:
				view_contact_info = view_sn_contact_info;
				break;
			case Value.VIEWID_PC:
				view_contact_info = view_cj_contact_info;
				break;
			case Value.VIEWID_KJ:
				view_contact_info = view_kj_contact_info;
				break;
			}
			if (view_contact_info != null
					&& view_contact_info.getVisibility() == View.VISIBLE) {
				showContactInfo();
			}
		}
	}
	@Override
	public void setCouponProgressBar(boolean isVisible) {
		ProgressBar pb_coupon = null;
		TextView tv_coupon=null;
		switch(mPresenter.getViewId()){
		case Value.VIEWID_SN:
			pb_coupon=pb_sn_coupon;
			tv_coupon=tv_sn_coupon;
			break;
		case Value.VIEWID_PC:
			pb_coupon=pb_cj_coupon;
			tv_coupon=tv_cj_coupon;
			break;
		case Value.VIEWID_KJ:
			pb_coupon=pb_kj_coupon;
			tv_coupon=tv_kj_coupon;
			break;
		}
		if(pb_coupon==null)return;
		if(isVisible){
			pb_coupon.setVisibility(View.VISIBLE);
			tv_coupon.setVisibility(View.GONE);
		}else{
			pb_coupon.setVisibility(View.GONE);
			tv_coupon.setVisibility(View.VISIBLE);
		}
		
		
	}
	@Override
	public void setPriceProgressBar(boolean isVisible) {
		ProgressBar pb_price = null;
		RelativeLayout layout_pb_price=null;
		switch(mPresenter.getViewId()){
		case Value.VIEWID_SN:
			pb_price=pb_sn_price;
			layout_pb_price=layout_pb_sn_price;
			break;
		case Value.VIEWID_PC:
			pb_price=pb_cj_price;
			layout_pb_price=layout_pb_cj_price;
			break;
		case Value.VIEWID_KJ:
			pb_price=pb_kj_price;
			layout_pb_price=layout_pb_kj_price;
			break;
		}
		if(pb_price==null)return;
		if(isVisible){
			pb_price.setVisibility(View.VISIBLE);
			layout_pb_price.setVisibility(View.VISIBLE);
		}else{
			pb_price.setVisibility(View.GONE);
			layout_pb_price.setVisibility(View.GONE);
		}
		
		
	}
	@SuppressWarnings("deprecation")
	@Override
	public void showCjType() {
		if(!mPresenter.isCJ())return;
		try{
		setEnabled(false);
		hideContactInfo(false);
		Drawable drawable = null;
		switch (main.getCjType()) {
		case PC:
			drawable = getResources().getDrawable(R.drawable.icon_rs);
			drawable.setBounds(0, 0, drawable.getMinimumWidth(),
					drawable.getMinimumHeight());
			layout_cj_label.setBackgroundDrawable(this.getResources()
					.getDrawable(R.drawable.label_bg_pc));
			if (tv_car_count != null) {
				tv_car_count.setCompoundDrawables(drawable, null, null, null);
				tv_car_count.setText(Html.fromHtml(String.format(
						context.getString(R.string.num),
						"<font color=\"#ff0000\">" + main.getCount()
								+ "</font>")));
			}
			if (cj_layout_cartype != null)
				cj_layout_cartype.setVisibility(View.GONE);
			if (cj_layout_rent != null)
				cj_layout_rent.setVisibility(View.GONE);

			cj_label_pc.setTextColor(getResources().getColor(R.color.blue));
			cj_label_bc.setTextColor(getResources().getColor(R.color.black));
			cj_label_sf.setTextColor(getResources().getColor(R.color.black));
			break;
		case BC:
			drawable = getResources().getDrawable(R.drawable.icon_car);
			drawable.setBounds(0, 0, drawable.getMinimumWidth(),
					drawable.getMinimumHeight());
			layout_cj_label.setBackgroundDrawable(this.getResources()
					.getDrawable(R.drawable.label_bg_bc));
			if (tv_car_count != null) {
				tv_car_count.setCompoundDrawables(drawable, null, null, null);
				tv_car_count.setText(Html.fromHtml(String.format(
						context.getString(R.string.num_car),
						"<font color=\"#ff0000\">" + main.getCount_BC()
								+ "</font>")));
			}

			cj_label_pc.setTextColor(getResources().getColor(R.color.black));
			cj_label_bc.setTextColor(getResources().getColor(R.color.blue));
			cj_label_sf.setTextColor(getResources().getColor(R.color.black));
			break;
		case SF:
			drawable = getResources().getDrawable(R.drawable.icon_rs);
			drawable.setBounds(0, 0, drawable.getMinimumWidth(),
					drawable.getMinimumHeight());
			layout_cj_label.setBackgroundDrawable(this.getResources()
					.getDrawable(R.drawable.label_bg_sf));
			if (tv_car_count != null) {
				tv_car_count.setCompoundDrawables(drawable, null, null, null);
				tv_car_count.setText(Html.fromHtml(String.format(
						context.getString(R.string.num),
						"<font color=\"#FF4343\">" + main.getCount()
								+ "</font>")));
			}
			if (cj_layout_cartype != null)
				cj_layout_cartype.setVisibility(View.GONE);
			if (cj_layout_rent != null)
				cj_layout_rent.setVisibility(View.GONE);

			cj_label_pc.setTextColor(getResources().getColor(R.color.black));
			cj_label_bc.setTextColor(getResources().getColor(R.color.black));
			cj_label_sf.setTextColor(getResources().getColor(R.color.blue));
			break;
		}
		}catch(Exception e){}
		main.setCjType(main.getCjType());
	}

	@Override
	public void showCityType() {
		new AsyncTask<Void, Void, Void>() {
			List<AppCitysBean> list_startcity=new ArrayList<AppCitysBean>();

			@Override
			protected Void doInBackground(Void... arg0) {
				list_startcity.addAll(ToCity2.getStartCityList(true));
				if (mApplication.loctionSnCity != null
						&& !mApplication.loctionSnCity.equals("")
						&& !mApplication.loctionSnCity
								.equals(getString(R.string.default_city))) {
					// 定位城市
					String str_location_city = mApplication.loctionSnCity
							.trim();
					//判断是否含有市内
					if(ToCity2.isContains(str_location_city,true)){
						ChildCitysBean mChildCitysBean=ToCity2.getEndChildCity(str_location_city,str_location_city,true);
						String incity_type=mChildCitysBean.getIncity_type();
						if(incity_type.equals(Value.CITY_APP)){
							showCityType(CITYTYPE.APP);
						}else if(incity_type.equals(Value.CITY_TEL)){
							showCityType(CITYTYPE.TEL);
						}else{
							showCityType(CITYTYPE.NOCITY);
						}
					}else{
						showCityType(CITYTYPE.NOCITY);
					}
				}else{
					showCityType(CITYTYPE.NOCITY);
				}
				return null;
			}

			@Override
			protected void onPostExecute(Void result) {
				if (mApplication.loctionSnCity != null
						&& !mApplication.loctionSnCity.equals("")
						&& !mApplication.loctionSnCity
								.equals(getString(R.string.default_city))) {

				}
				super.onPostExecute(result);
			}

		}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
	}

	public RelativeLayout layout_no_incity;
	public LinearLayout layout_tel;
	public RelativeLayout iv_tel;
	private View view_tel;
	private View view_nocity;
	public TextView tv_city_tel;
	private WaveView mWaveView;
	String xiadanTel = "";
	public CITYTYPE Citytype = null;

	@Override
	public void showCityType(final CITYTYPE type) {
		Citytype = type;
		if (!mPresenter.isCity())
			return;
		runOnUiThread(new Runnable() {
			@Override
			public void run() {
				switch (type) {
				case APP:
					if (layout_no_incity != null) {
						layout_no_incity.setVisibility(View.GONE);
					}
					if (layout_tel != null) {
						layout_tel.setVisibility(View.GONE);
					}
					break;
				case TEL:
					if (view_tel == null) {
						ViewStub stub_tel = (ViewStub) findViewById(R.id.stub_tel);
						view_tel = stub_tel.inflate();
						layout_tel = (LinearLayout) view_tel
								.findViewById(R.id.layout_tel);
						tv_city_tel = (TextView) view_tel
								.findViewById(R.id.tv_city_tel);
						iv_tel = (RelativeLayout) view_tel
								.findViewById(R.id.iv_tel);
						iv_tel.setOnClickListener(MainActivity.this);
					}
					if (layout_no_incity != null) {
						layout_no_incity.setVisibility(View.GONE);
					}
					layout_tel.setVisibility(View.VISIBLE);
					tv_city_tel.setText(xiadanTel);
					mWaveView = (WaveView) view_tel
							.findViewById(R.id.wave_view);
					mWaveView.setDuration(5000);
					mWaveView.setStyle(Paint.Style.FILL);
					mWaveView.setSpeed(1000);
					mWaveView.setColor(getResources().getColor(R.color.blue));
					mWaveView.setInterpolator(new DecelerateInterpolator());
					mWaveView.start();

					break;
				case NOCITY:
					if (view_nocity == null) {
						ViewStub stub_nocity = (ViewStub) findViewById(R.id.stub_nocity);
						view_nocity = stub_nocity.inflate();
						layout_no_incity = (RelativeLayout) view_nocity
								.findViewById(R.id.layout_no_incity);
					}
					layout_no_incity.setVisibility(View.VISIBLE);
					if (layout_tel != null) {
						layout_tel.setVisibility(View.GONE);
					}
					break;
				}

				// TODO Auto-generated method stub

			}
		});

	}

	@Override
	public void showTimeSelector(View v) {
		DatePicker2 mDatePicker = DatePicker2.getInstance(this);
		final CustomPicker pvCustom;
		if (mPresenter.isCity()) {
			mDatePicker.setMaxDay(5);
		} else {
			mDatePicker.setMaxDay(15);
		}
		pvCustom = mDatePicker.showDate();
		pvCustom.show();
		pvCustom.setOnScrollResultListener(new CustomPicker.OnScrollResultListener() {
			@Override
			public void onScrollResult(int[] index) {
				//现在出发
				if (index[0] == 0) {
					pvCustom.setCurrentItems(0, 0, 0);
				}
				//今天
				else if (index[0] == 1) {
					int jiange = 10;
					long Time = DateFormat.getTime() + 30 * 60 * 1000;// 加30分上去，是为了不让选择当前时间+30分以下的时间
					Calendar mCalendar = Calendar.getInstance();
					mCalendar.setTimeInMillis(Time);
					int hour = mCalendar.get(Calendar.HOUR_OF_DAY);
					int minute = mCalendar.get(Calendar.MINUTE);
					mCalendar.setTimeInMillis(DateFormat.getTime());
//					如果选择的小时小于当前时间的小时
					int xiaoshi = -1;
					try {
						xiaoshi = Integer.parseInt(pvCustom.getData()[1].get(index[1]) + "");
					} catch (Exception e) {
					}
					if (xiaoshi <= (hour) || index[1] == 0 || index[2] == 0) {
						//由于0的位置是"-",1的位置是“00”，所以当前hour的位置就是+1
						int hour_index = hour + 1;
						//如果分钟时间大于最后一个，则还要在进1
						try {
							if (minute > Integer.parseInt(pvCustom.getData()[2].get(pvCustom.getData()[2].size() - 1) + "")) {
								hour_index = hour_index + 1;
							}
						} catch (Exception e) {
						}
						int minute_index = 0;
						for (int i = 0; i < pvCustom.getData()[2].size(); i++) {
							int fen = -1;
							try {
								fen = Integer.parseInt(pvCustom.getData()[2].get(i) + "");
							} catch (Exception e) {
							}
							if (fen >= minute) {
								minute_index = i;
								break; // 跳出外层循环
							}
						}
						if (minute_index == 0) minute_index = 1;
						pvCustom.setCurrentItems(index[0], hour_index, minute_index);
					}
				}
				//今天以后，如果时间在“-”的位置，则要移动到“00”
				else {
					if (index[1] == 0||index[2] == 0) {
						pvCustom.setCurrentItems(index[0], 1, 1);
					}
				}
			}
		});
		pvCustom.setCustomSelectListener(new CustomPicker.OnCustomSelectListener() {
			@Override
			public void onCustomSelect(int[] index) {
				pvCustom.dismiss();
				mPresenter.setIsTimeChanged(false);
				//现在出发
				if (index[0] == 0) {
					mPresenter.setIsTimeChanged(true);
					main.setTime(pvCustom.getData()[0].get(index[0]) + "",
							mPresenter.isCity());
					if (mPresenter.isCity()) {
						mPresenter.shareView(SHAREVIEW_TYPE.sn,
								SHAREVIEW_TYPE2.time);
					} else {
						mPresenter.shareView(SHAREVIEW_TYPE.share,
								SHAREVIEW_TYPE2.time);
					}

					if (mPresenter.getIsTimeChanged()) {
						mPresenter.setRecommendForOrderTimeChanged();
					}
				}
				//不是现在出发
				else {
					String mTime = DatePicker2.getInstance(context).onTimeFormat(
							pvCustom.getData()[0].get(index[0]) + "",
							pvCustom.getData()[1].get(index[1]) + "",
							pvCustom.getData()[2].get(index[2]) + "");
					mPresenter.setIsTimeChanged(true);
					main.setTime(mTime, mPresenter.isCity());
					if (mPresenter.isCity()) {
						mPresenter.shareView(SHAREVIEW_TYPE.sn,
								SHAREVIEW_TYPE2.time);
					} else {
						mPresenter.shareView(SHAREVIEW_TYPE.share,
								SHAREVIEW_TYPE2.time);
					}
					if (mPresenter.getIsTimeChanged()) {
						if (!main.isStartRecommend) {
							mPresenter.setRecommendForOrderTimeChanged();
						}
					}
				}
			}
		});
	}

	@Override
	public void setThanks_fee() {
		int num_thanks_fee_id = 0;
		int schedule_fee_id = 0;
		switch(VersionUtils.getVersionType(context)){
		  case bbx:
			  num_thanks_fee_id=R.string.num_thanks_fee;
			  schedule_fee_id=R.string.schedule_fee;
			  break;
		  case tianshang:
			  num_thanks_fee_id=R.string.num_thanks_fee2;
			  schedule_fee_id=R.string.schedule_fee2;
			  break;
		}
		if (main.getThanksfee() != 0) {
			tv_thanks_fee.setText(Html.fromHtml(String.format(
					this.getString(num_thanks_fee_id),
					"<font color=\"#ff0000\">" + main.getThanksfee()
							+ "</font>")));
		} else {
			tv_thanks_fee.setText(this.getString(schedule_fee_id));
		}
		mPresenter.setActualprice(mPresenter.getPrice(), mPresenter.getCouponSum(),main.getThanksfee() * 100);
		TextView tv_pay = null;
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			;
			tv_pay = tv_sn_pay;
			break;
		case Value.VIEWID_PC:
			tv_pay = tv_cj_pay;
			break;
		case Value.VIEWID_KJ:
			tv_pay = tv_kj_pay;
			break;
		}
		tv_pay.setText(FormatUtil.onFormatPrice(mPresenter.getActualprice()));
	}

	@Override
	public void shareViewSN(boolean isContentFilling) {
		try {
			if (!mPresenter.isCity())
				return;
			if (mPresenter.getShareListSn() == null
					|| mPresenter.getShareListSn().isEmpty()) {
				return;
			}
			String start = main.getStartName(true);
			String end = main.getEndName(true);
			for (int i = 0; i < mPresenter.getShareListSn().size(); i++) {
				SHAREVIEW_TYPE2 TYPE = mPresenter.getShareListSn().get(i);
				switch (TYPE) {
				case time:
					String time = main.getTime(true);
					if (time != null
							&& !time.equals(tv_sn_time.getText().toString()))
						tv_sn_time.setText(time);
					break;
				case start:
					mPresenter.setRecordLastAddr(LastAddr.start);
					if (start != null
							&& !start.equals(tv_sn_start_address.getText()
									.toString())) {
						mPresenter.setOldCity(main.getStartCity());
						tv_sn_start_address.setText(start);
					}
					 if (mPresenter.isPriceInfo()) {
					 showPriceInfo();
					 } else {
					 hidePriceInfo(false);
					 }
					break;
				case end:
					mPresenter.setRecordLastAddr(LastAddr.end);
					if (end != null
							&& !end.equals(tv_sn_end_address.getText()
									.toString())) {
						tv_sn_end_address.setText(end);
					}
					 if (mPresenter.isPriceInfo()) {
					 showPriceInfo();
					 } else {
					 hidePriceInfo(false);
					 }
					break;
				case name:
					if (main.getName() != null && main.getTel() != null
							&& !main.getTel().equals("")) {
						if (tv_sn_telephone != null)
							tv_sn_telephone
									.setText((main.getName().equals("") ? this
											.getString(R.string.i) : main
											.getName())
											+ "-"
											+ FormatUtil.onFormatTelephone(main
													.getTel()));
					}
					break;
				case location:
//					 if(Citytype==null){
//					 onLocationResult();
//					 }else{
//					 showCityType(Citytype);
//					 }
					break;
				case thanks_fee:
					// setThanks_fee();
					break;
				}
				if (i >= mPresenter.getShareListSn().size() - 1) {
					mPresenter.getShareListSn().clear();
					if (isContentFilling) {
						onContentFilling();
					}
				}
			}
		} catch (Exception e) {
		}
	}

	@Override
	public void shareViewCJ(boolean isContentFilling) {
		try {
			if (!mPresenter.isCJ())
				return;
			if (mPresenter.getShareListPc() == null
					|| mPresenter.getShareListPc().isEmpty()) {
				return;
			}
			String start = main.getStartName();
			String end = main.getEndName();
			for (int i = 0; i < mPresenter.getShareListPc().size(); i++) {
				SHAREVIEW_TYPE2 TYPE = mPresenter.getShareListPc().get(i);
				switch (TYPE) {
				case time:
					String time = main.getTime(false);
					if (time != null
							&& !time.equals(tv_cj_time.getText().toString()))
						tv_cj_time.setText(time);
					break;
				case start:
					mPresenter.setRecordLastAddr(LastAddr.start);
					if (!TextUtils.isEmpty(start)) {
						tv_cj_start_address.setText(start);
						mPresenter.setOldCity(main.getStartCity());
						setRecommendStartVisibility(main.isStartRecommend);
					} else {
						setRecommendStartVisibility(false);
						main.isStartRecommend = false;
						tv_cj_start_address.setText(start);
					}
					 if (mPresenter.isPriceInfo()) {
					 showPriceInfo();
					 } else {
					 hidePriceInfo(false);
					 }
					break;
				case end:
					mPresenter.setRecordLastAddr(LastAddr.end);
					if (!TextUtils.isEmpty(end)) {
						tv_cj_end_address.setText(end);
						setRecommendEndVisibility(main.isEndRecommend);
					} else {
						setRecommendEndVisibility(false);
						main.isEndRecommend = false;
						tv_cj_end_address.setText(end);
					}
					 if (mPresenter.isPriceInfo()) {
					 showPriceInfo();
					 } else {
					 hidePriceInfo(false);
					 }
					break;
				case name:
					if (main.getName() != null && main.getTel() != null
							&& !main.getTel().equals("")) {
						if (tv_cj_telephone != null)
							tv_cj_telephone
									.setText((main.getName().equals("") ? this
											.getString(R.string.i) : main
											.getName())
											+ "-"
											+ FormatUtil.onFormatTelephone(main
													.getTel()));
					}
					break;
				case location:
					// if(Citytype==null){
					// onLocationResult();
					// }else{
					// showCityType(Citytype);
					// }
					break;
				case thanks_fee:
					// setThanks_fee();
					break;
				}
				if (i >= mPresenter.getShareListPc().size() - 1) {
					mPresenter.getShareListPc().clear();
					if (isContentFilling) {
						onContentFilling();
					}
				}
			}
		} catch (Exception e) {
		}
	}

	@Override
	public void shareViewKJ(boolean isContentFilling) {
		try {
			if (!mPresenter.isKJ())
				return;
			// 有出发地和目的地，但是没有收件人的时候，显示覆盖物，，如果都有的话，会在请求价格的时候显示覆盖物
			if (mPresenter.isShowStartEnd()&&!mPresenter.isNoEndName()) {
				showStartAndEnd();
			}
			if (mPresenter.getShareListKj() == null
					|| mPresenter.getShareListKj().isEmpty()) {
				return;
			}
			String start = main.getStartName();
			String end = main.getEndName();
			for (int i = 0; i < mPresenter.getShareListKj().size(); i++) {
				SHAREVIEW_TYPE2 TYPE = mPresenter.getShareListKj().get(i);
				switch (TYPE) {
				case time:
					String time = main.getTime(false);
					if (time != null
							&& !time.equals(tv_kj_time.getText().toString()))
						tv_kj_time.setText(time);
					break;
				case start:
					mPresenter.setRecordLastAddr(LastAddr.start);
					if (!TextUtils.isEmpty(start)) {
						tv_kj_start_address.setText(start);
						mPresenter.setOldCity(main.getStartCity());
						setRecommendStartVisibility(main.isStartRecommend);
					} else {
						setRecommendStartVisibility(false);
						main.isStartRecommend = false;
						tv_kj_start_address.setText(start);
					}
					 if (mPresenter.isPriceInfo()) {
					 showPriceInfo();
					 } else {
					 hidePriceInfo(false);
					 }
					break;
				case end:
					mPresenter.setRecordLastAddr(LastAddr.end);
					if (!TextUtils.isEmpty(end)) {
						tv_kj_end_address.setText(end);
						setRecommendEndVisibility(main.isEndRecommend);
					} else {
						setRecommendEndVisibility(false);
						main.isEndRecommend = false;
						tv_kj_end_address.setText(end);
					}
					 if (mPresenter.isPriceInfo()) {
					 showPriceInfo();
					 } else {
					 hidePriceInfo(false);
					 }
					break;
				case name:
					if (main.getName() != null && main.getTel() != null
							&& !main.getTel().equals("")) {
						if (tv_kj_telephone != null)
							tv_kj_telephone
									.setText((main.getName().equals("") ? this
											.getString(R.string.i) : main
											.getName())
											+ "-"
											+ FormatUtil.onFormatTelephone(main
													.getTel()));
					}
					break;
				case name2:
					if (main.getName2() != null && !main.getName2().equals("")
							&& main.getTel2() != null
							&& !main.getTel2().equals("")) {
						if (tv_kj_end_person != null)
							tv_kj_end_person.setText(main.getName2()
									+ "-"
									+ FormatUtil.onFormatTelephone(main
											.getTel2()));
					} else {
						tv_kj_end_person.setText("");
					}
					 if (mPresenter.isPriceInfo()) {
						 showPriceInfo();
						 } else {
						 hidePriceInfo(false);
					 }
					break;
				case location:
					// if(Citytype==null){
					// onLocationResult();
					// }else{
					// showCityType(Citytype);
					// }
					break;
				case thanks_fee:
					// setThanks_fee();
					break;
				}
				if (i >= mPresenter.getShareListKj().size() - 1) {
					mPresenter.getShareListKj().clear();
					if (isContentFilling) {
						onContentFilling();
					}
				}
			}
		} catch (Exception e) {
		}
	}
	@Override
	public void setAnchor() {
		// 出发地为空的时候
		if (!mPresenter.isNoStartNull()) {
			if (mPresenter.getAnchorIsYichu()) {
				layout_nearcount.setVisibility(View.GONE);
				layout_myposition.setVisibility(View.VISIBLE);
				tv_myposition.setText(mPresenter.getAnchorText());
			} else {
				layout_myposition.setVisibility(View.GONE);
			}
			clearMarker_Fujian();
		}else{
			if (mPresenter.isCity()) {
				layout_nearcount.setVisibility(View.VISIBLE);
				tv_myposition.setText(getString(R.string.myposition_oncar));
				mPresenter.setAnchorText(tv_myposition.getText().toString());
			} else {
				layout_nearcount.setVisibility(View.GONE);
				String name = main.getStartName(mPresenter.isCity());
				if (name != null && !name.equals("")) {
					tv_myposition.setText(main.getStartName(mPresenter.isCity()));
					mPresenter.setAnchorText(tv_myposition.getText().toString());
				}
			}
		}
	}
	@Override
	public void setBaseDiscountText() {
		TextView iv_base_discount = null;
		switch(mPresenter.getViewId()){
		case Value.VIEWID_SN:
			iv_base_discount=sn_iv_base_discount;
			break;
		case Value.VIEWID_PC:
			iv_base_discount=cj_iv_base_discount;
			break;
		case Value.VIEWID_KJ:
			iv_base_discount=kj_iv_base_discount;
			break;
		}
		if(iv_base_discount==null)return;
		if(mPresenter.getBaseDiscount()>1){
			iv_base_discount.setVisibility(View.VISIBLE);
			iv_base_discount.setText(mPresenter.getBaseDiscount()+"倍");
		}else if(mPresenter.getBaseDiscount()<1){
			iv_base_discount.setVisibility(View.VISIBLE);
			iv_base_discount.setText(mPresenter.getBaseDiscount()*10+"折");
		}else{
			iv_base_discount.setVisibility(View.GONE);
		}
		
	}
	@Override
	public void hidePriceDetail() {
		TextView tv_usablesale = null;
		TextView iv_base_discount = null;
		switch(mPresenter.getViewId()){
		case Value.VIEWID_SN:
			iv_base_discount=sn_iv_base_discount;
			tv_usablesale=sn_tv_usablesale;
			break;
		case Value.VIEWID_PC:
			iv_base_discount=cj_iv_base_discount;
			tv_usablesale=cj_tv_usablesale;
			break;
		case Value.VIEWID_KJ:
			iv_base_discount=kj_iv_base_discount;
			tv_usablesale=kj_tv_usablesale;
			break;
		}
		if(iv_base_discount!=null)iv_base_discount.setVisibility(View.GONE);
		if(tv_usablesale!=null)tv_usablesale.setVisibility(View.GONE);
	}
	@Override
	public void showDragThanks() {
		MessageDialog.onThanksFeeDialog(context,main.getThanksfee() * 100);

//		try{
//		thanks_dragLayout.open();
//		thanks_dragLayout.setDetail(this,mPresenter,main.getThanksfee() * 100, mPresenter.getCarType()
//				.getList(),mPresenter.getRentId(),mPresenter.getCarClassId());
		
		
		//现在取消了，省钱秘籍，所以可以不用跳转到其他界面了
//	    Intent intent=new Intent(this,ThanksFeeActivity.class);
//	    Bundle mBundle=new Bundle();
//	    mBundle.putDouble(ThanksFeeMsg.thanksfee,main.getThanksfee() * 100);
//	    mBundle.putInt(ThanksFeeMsg.rent_id,mPresenter.getRentId());
//	    mBundle.putString(ThanksFeeMsg.car_class_id,mPresenter.getCarClassId());
//	    intent.putExtras(mBundle);
//		ThanksFeeMsg.list=mPresenter.getCarType().getList();
//		onStartActivityForResult2(intent,ThanksFeeMsg.code);
//		}catch(Exception e){}
	}
	@Override
	public void showDragAddFee() {
		add_dragLayout.open();
		double price,base_price = 0,base_discount,coupon = 0;
		price=mPresenter.getActualprice();
		try{
			base_price=mPresenter.getBasePrice();
		 }catch(Exception e){}
		base_discount=mPresenter.getBaseDiscount();
		switch(mPresenter.getSaleType()){
		case UsableSale.sale_type_no:
			coupon=mPresenter.getCouponSum();
			break;
		case UsableSale.sale_type_submit:
			coupon=mPresenter.getSaleAmount();
			break;
		case UsableSale.sale_type_online:
			coupon=mPresenter.getSaleAmount();
			break;
		}
		add_dragLayout.setDetail(mPresenter,price,base_price, base_discount, coupon,mPresenter.getSaleType());
	}
	@Override
	public void showDragPrice() {
		try {
		dragLayout.setLoadView(mPresenter.getLoadView());
		BlurBuilder.GetandSaveCurrentImage(MainActivity.this, mMapView);
		mHandler.postDelayed(new Runnable() {
			@Override
			public void run() {
				 double coupon=0;
				switch(mPresenter.getSaleType()){
				case UsableSale.sale_type_no:
					coupon=mPresenter.getCouponSum();
					break;
				case UsableSale.sale_type_submit:
					coupon=mPresenter.getSaleAmount();
					break;
				case UsableSale.sale_type_online:
					coupon=mPresenter.getSaleAmount();
					break;
				}
				dragLayout.setDetail(mPresenter.getActualprice(),
						mPresenter.getDiscountPrice(),coupon,
						mPresenter.isCity() ? main.getThanksfee() * 100
								: 0,mPresenter.getSaleType(),mPresenter.getBaseDiscount());
				if (mPresenter.getCarType() != null
						&& mMeteredFee != null
						&& mPresenter.getCarType() != null
						&& mPresenter.getCarType().getList() != null) {
					CarData mCarData = mPresenter.getCarType()
							.getList().get(mPresenter.getCarTypeId()).getList()
							.get(mPresenter.getRentId());
					dragLayout.setCombo(mPresenter,mCarData, mMeteredFee,main.getBusinessType(mPresenter.getViewId()),
							main.getCalcType(mPresenter.getViewId()));
				} else {
					dragLayout.setCombo(mPresenter,null,null, main.getBusinessType(mPresenter.getViewId()),
							main.getCalcType(mPresenter.getViewId()));

				}
			}
		}, 0);
	} catch (Exception e) {
	}}
	ScrollView scrollview = null;

	public void fullScroll() {

		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			scrollview = sn_scrollview;
			break;
		case Value.VIEWID_PC:
			scrollview = cj_scrollview;
			break;
		case Value.VIEWID_KJ:
			scrollview = kj_scrollview;
			break;
		}
		if (scrollview == null)
			return;
		mHandler.postDelayed(new Runnable() {

			@Override
			public void run() {
				scrollview.fullScroll(ScrollView.FOCUS_DOWN);
			}
		}, 600);

	}

	View cj_view_start_tj;
	View kj_view_start_tj;

	@Override
	public void setRecommendStartVisibility(boolean isVisible) {
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_PC:
			if (view_cj_address != null) {
				if (cj_view_start_tj == null) {
					ViewStub stub_start_tj = (ViewStub) view_cj_address
							.findViewById(R.id.stub_start_tj);
					cj_view_start_tj = stub_start_tj.inflate();
					cj_view_start_tj.setVisibility(isVisible ? View.VISIBLE
							: View.GONE);
				} else {
					cj_view_start_tj.setVisibility(isVisible ? View.VISIBLE
							: View.GONE);
				}
			}
			break;
		case Value.VIEWID_KJ:
			if (view_kj_address != null) {
				if (kj_view_start_tj == null) {
					ViewStub stub_start_tj = (ViewStub) view_kj_address
							.findViewById(R.id.stub_start_tj);
					kj_view_start_tj = stub_start_tj.inflate();
					kj_view_start_tj.setVisibility(isVisible ? View.VISIBLE
							: View.GONE);
				} else {
					kj_view_start_tj.setVisibility(isVisible ? View.VISIBLE
							: View.GONE);
				}
			}
			break;
		}
	}

	View cj_view_end_tj;
	View kj_view_end_tj;

	@Override
	public void setRecommendEndVisibility(boolean isVisible) {
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_PC:
			if (view_cj_address != null) {
				if (cj_view_end_tj == null) {
					ViewStub stub_end_tj = (ViewStub) view_cj_address
							.findViewById(R.id.stub_end_tj);
					cj_view_end_tj = stub_end_tj.inflate();
					cj_view_end_tj.setVisibility(isVisible ? View.VISIBLE
							: View.GONE);
				} else {
					cj_view_end_tj.setVisibility(isVisible ? View.VISIBLE
							: View.GONE);
				}
			}
			break;
		case Value.VIEWID_KJ:
			if (view_kj_address != null) {
				if (kj_view_end_tj == null) {
					ViewStub stub_end_tj = (ViewStub) view_kj_address
							.findViewById(R.id.stub_end_tj);
					kj_view_end_tj = stub_end_tj.inflate();
					kj_view_end_tj.setVisibility(isVisible ? View.VISIBLE
							: View.GONE);
				} else {
					kj_view_end_tj.setVisibility(isVisible ? View.VISIBLE
							: View.GONE);
				}
			}
			break;
		}
	}

	@Override
	public void setHandler(int msg) {
		mHandler.sendEmptyMessage(msg);
	}

	@Override
	public void notifiExtras(int order_status, String order_id) {
		StartOrderUtils.onStartOrder(context,order_status, order_id,BaseBBXActivity.requestCode);
	}

	@Override
	public void showOrderListIng(final int isVisible, final String title) {
		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				if (title != null && !title.equals("")
						&& !title.equals(tv_prompt.getText().toString())) {
					tv_prompt.setText(title);
				}
				if (isVisible == layout_prompt.getVisibility()) {
					return;
				}
				layout_prompt.setVisibility(isVisible);
				showStartAndEnd();
			}
		}, 500);

	}

	@Override
	public void onOrderSubmitFinish() {
		Intent intent = new Intent(context, StartServiceActivity.class);
		intent.putExtra(OrderMsg.extra_type, 0);
		onStartActivityForResult(intent, requestCode);
	}

	@Override
	public void setConfirm(boolean isShow) {
		if (isShow&& layout_confirm.getVisibility() == View.GONE) {
			layout_confirm.setVisibility(View.VISIBLE);
			confirm.setVisibility(View.VISIBLE);
			confirm.setGravity(Gravity.CENTER);
			fullScroll();
		} else if (!isShow && layout_confirm.getVisibility() == View.VISIBLE) {
			layout_confirm.setVisibility(View.GONE);
			confirm.setVisibility(View.GONE);
			setEnabled(false);
		}
	}

	@Override
	public void setEnabled(boolean isEnanled) {
		confirm.setEnabled(isEnanled);
		if (isEnanled) {
			if (mPresenter.isCity()) {
				if (main.getCalcType(mPresenter.getViewId()) == CarType.CALC_TYPE_dabiao) {// 打表
					showPriceRemind(true, "以计价器为准");
				} else {
					showPriceRemind(false, null);
				}

			}
			showStartAndEnd();
		} else {
		}
		setHandler(MainPresenter.DIALOG_DISMISS);
	}
    public static String remind_price="价格请咨询客服";
    private String remind_line="线路暂未开通";
	TextView tv_remind = null;
	RelativeLayout layout_remind;
	RelativeLayout layout_pay = null;
	@Override
	public void showPriceRemind(final boolean isShow,final String text) {
		// 这边做延迟，主要是因为别的地方在做动画，所以会出现闪一下
		mHandler.postDelayed(new Runnable() {
			@Override
			public void run() {
				switch (mPresenter.getViewId()) {
				case Value.VIEWID_SN:
					tv_remind = tv_sn_remind;
					layout_remind=layout_sn_remind;
					layout_pay = layout_sn_pay;
					break;
				case Value.VIEWID_PC:
					tv_remind = tv_cj_remind;
					layout_remind=layout_cj_remind;
					layout_pay = layout_cj_pay;
					break;
				case Value.VIEWID_KJ:
					tv_remind = tv_kj_remind;
					layout_remind=layout_kj_remind;
					layout_pay = layout_kj_pay;
					break;
				}
				if (tv_remind == null || layout_pay == null||layout_remind==null)
					return;
				if (isShow) {
					layout_pay.setVisibility(View.INVISIBLE);
					
					tv_remind.postDelayed(new Runnable() {
						@Override
						public void run() {
							tv_remind.setVisibility(View.VISIBLE);
							layout_remind.setVisibility(View.VISIBLE);
							if (text != null
									&& !tv_remind.getText().toString().equals(text))
								tv_remind.setText(text);
						}
					}, 0);
				
				} else {
					layout_pay.setVisibility(View.VISIBLE);
					tv_remind.setVisibility(View.INVISIBLE);
					layout_remind.setVisibility(View.INVISIBLE);
				}
			}
		}, 0);

	}

	@Override
	public boolean getPriceRemid() {
		TextView tv_remind = null;
		RelativeLayout layout_remind = null;
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			tv_remind = tv_sn_remind;
			layout_remind=layout_sn_remind;
			break;
		case Value.VIEWID_PC:
			tv_remind = tv_cj_remind;
			layout_remind=layout_cj_remind;
			break;
		case Value.VIEWID_KJ:
			tv_remind = tv_kj_remind;
			layout_remind=layout_kj_remind;
			break;
		}
		if (tv_remind == null||layout_remind==null)
			return false;
		if (tv_remind.getVisibility() == View.VISIBLE&&layout_remind.getVisibility() == View.VISIBLE)
			return true;
		return false;
	}
	@Override
	public void setCouponResult(Intent data) {
		if(data==null)return;
		try{
		double coupon_sum = data.getExtras().getInt(UseCouponMsg.sum);
		boolean isMarkOnline = data.getExtras().getBoolean(
				UseCouponMsg.coupon_online);
		int coupon_type = data.getExtras().getInt(
				UseCouponMsg.coupon_type);
		int coupon_id = data.getExtras().getInt(UseCouponMsg.coupon_id);
		setCouponInfo(coupon_sum, coupon_type, coupon_id);
		boolean isMarkOnlineDialog = SharedPreUtil.getBooleanValue(
				this, SharedPreEncryptUtil.isMarkOnlineDialog, true);
		if (isMarkOnline && isMarkOnlineDialog) {
			final MyAlertDailog dialog = new MyAlertDailog(this);
			dialog.setTitle(getString(R.string.mydailog_title2));
			dialog.setContent2(getString(R.string.mydailog_content_markonline));
			dialog.setLeftButtonText(getString(R.string.mydailog_not_remind));
			dialog.setRightButtonText(getString(R.string.mydailog_know));
			if (dialog != null && !dialog.isShowing()) {
				dialog.show();
			}
			dialog.setOnClickLeftListener(new onClickLeftListener() {

				@Override
				public void onClickLeft() {
					if (dialog != null) {
						dialog.dismiss();
					}
					SharedPreUtil.putBooleanValue(MainActivity.this,
							SharedPreEncryptUtil.isMarkOnlineDialog,
							false);
				}
			});
			dialog.setOnClickRightListener(new onClickRightListener() {

				@Override
				public void onClickRight() {
					if (dialog != null) {
						dialog.dismiss();
					}
				}
			});

		}
		}catch(Exception e){}
	}
	@Override
	public void setCouponInfo(double coupon_sum, int coupon_type, int coupon_id) {
		//显示立减活动
		if(coupon_id==0){
			onUsableSale(mPresenter.getUsableSale());
		}else{
			mPresenter.setSaleType(0);
			mPresenter.setSaleAmount(0);
			onUsableSale(null);
		}
		mPresenter.setActualprice(mPresenter.getPrice(),coupon_sum * 100,main.getThanksfee() * 100);
		mPresenter.setCouponSum(coupon_sum * 100);
		mPresenter.setCouponId(coupon_id);
		TextView tv_coupon = null;
		TextView tv_pay = null;
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			tv_coupon = tv_sn_coupon;
			tv_pay = tv_sn_pay;
			break;
		case Value.VIEWID_PC:
			tv_coupon = tv_cj_coupon;
			tv_pay = tv_cj_pay;
			break;
		case Value.VIEWID_KJ:
			tv_coupon = tv_kj_coupon;
			tv_pay = tv_kj_pay;
			break;
		}
		if (tv_pay == null || tv_coupon == null)
			return;
		// 根据不同的优惠劵处理不同
		switch (coupon_type) {
		case CouponUtils.coupon_type_0:
		case CouponUtils.coupon_type_3:
			tv_coupon.setText(Html.fromHtml(String.format(
					context.getString(R.string.coupon_deductible),
					"<font color=\"#fe5000\">"
							+ FormatUtil.onFormatDecimal(coupon_sum)
							+ "</font>")));
			break;
		case CouponUtils.coupon_type_1:
			// if (mPresenter.getViewId() == Value.VIEWID_SN) {
			// tv_coupon_text.setVisibility(View.GONE);
			// tv_coupon_deductible.setText((Html.fromHtml(sum / 10
			// + "<font color=\"#313438\">" + "折优惠"
			// + "</font>")));
			// } else {
			// sum = CouponUtils.getZhekouSum(mPresenter.getPrice(),
			// sum);
			// actual_price = mPresenter.getPrice() - sum * 100;
			// tv_coupon_deductible.setText("" + sum);
			// tv_coupon_text.setVisibility(View.VISIBLE);
			// tv_price.setText(String
			// .format(getString(R.string.coupon_deductible),
			// FormatUtil.onFormatPrice(mPresenter
			// .getPrice())));
			// }
			break;
		case CouponUtils.coupon_type_2:
			// if (mPresenter.getViewId() == Value.VIEWID_SN) {
			// tv_coupon_text.setVisibility(View.GONE);
			// tv_coupon_deductible.setText((Html.fromHtml(+sum / 10
			// + "<font color=\"#313438\">" + "元体验"
			// + "</font>")));
			// } else {
			// sum = CouponUtils.getTiyanSum(mPresenter.getPrice(),
			// sum);
			// actual_price = mPresenter.getPrice() - sum * 100;
			// tv_price.setText(String
			// .format(getString(R.string.coupon_deductible),
			// FormatUtil.onFormatPrice(mPresenter
			// .getPrice())));
			// tv_coupon_deductible.setText("" + sum);
			// tv_coupon_text.setVisibility(View.VISIBLE);
			// }
			break;
		}

		if (coupon_sum == 0) {
			tv_coupon.setText(this.getString(R.string.coupon_not_used));
		}
		if (mPresenter.isCity()) {
			if (main.getCalcType(mPresenter.getViewId()) == CarType.CALC_TYPE_dabiao) {// 打表
				showPriceRemind(true, "以计价器为准");
			} else {
				showPriceRemind(false, null);
			}

		}
		tv_pay.setText(FormatUtil.onFormatPrice(mPresenter.getActualprice()));

	}

	@Override
	public void clearCouponInfo() {
		mPresenter.setActualprice(0,0,0);
		mPresenter.setCouponSum(0);
		mPresenter.setCouponId(0);
		TextView tv_coupon = null;
		TextView tv_pay = null;
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			tv_coupon = tv_sn_coupon;
			tv_pay = tv_sn_pay;
			break;
		case Value.VIEWID_PC:
			tv_coupon = tv_cj_coupon;
			tv_pay = tv_cj_pay;
			break;
		case Value.VIEWID_KJ:
			tv_coupon = tv_kj_coupon;
			tv_pay = tv_kj_pay;
			break;
		}
		if (tv_pay == null || tv_coupon == null)
			return;
		tv_coupon.setText(this.getString(R.string.coupon_not_used));
		tv_pay.setText(FormatUtil.onFormatPrice(mPresenter.getActualprice()));

	}

	@Override
	public void showHasCoupon() {
		// TODO Auto-generated method stub

	}

	@Override
	public void showdetaileCoupon() {
		// TODO Auto-generated method stub

	}

	@Override
	public void hideCoupon() {
		// TODO Auto-generated method stub

	}

	@Override
	public void hideCouponAndPriceInVisible() {
		// TODO Auto-generated method stub

	}

	@Override
	public void hideCouponAndPriceGone() {
		// TODO Auto-generated method stub

	}

	@Override
	public void showMap() {
		ViewStub map_stub = (ViewStub) findViewById(R.id.map_stub);
		if (mMapView == null) {
			View map_view = map_stub.inflate();
			map_stub.setVisibility(View.VISIBLE);
			mMapView = (MapView) map_view.findViewById(R.id.bmapView);
			// 先隐藏在显示，以免显示桌面等问题
			mMapView.setVisibility(View.INVISIBLE);
			mMapView.postDelayed(new Runnable() {
				@Override
				public void run() {
					mMapView.setVisibility(View.VISIBLE);
				}
			}, 200);
			MyBaiduMap.initDefaultLocation(this, mMapView);
			initmap();
		}

	}

	@Override
	public void showNoSfDailog() {
		runOnUiThread(new Runnable() {
			@Override
			public void run() {
				final MyAlertDailog mydialog = new MyAlertDailog(
						context);
				mydialog.setTitle(context
						.getString(R.string.mydailog_title));
				mydialog.setContent(context
						.getString(R.string.sf_line_no));
				mydialog.setSingle(context
						.getString(R.string.mydailog_confirm2));
				showPriceRemind(true, remind_line);
				mydialog.setOnClickSingleListener(new onClickSingleListener() {
					@Override
					public void onClickSingle() {
						if(cj_label_pc!=null)cj_label_pc.performClick();
					}
				});
				mydialog.show();
			}
		});

	}

	@Override
	public void onNotify(int type, JSONObject jb, Data msgs_data) {
		switch (type) {
		case GMsg.OFFLINE:
			if (mApplication.getUid() != null && !mApplication.equals("")
					&& mApplication.getToken() != null
					&& !mApplication.getToken().equals("")) {
				if (mApplication != null) {
					MyOrderingTask.getInstance(context)
							.setOnOrderingFinishListener(this);
					MyOrderTask.getInstance(context, MyOrderActivity.num_all2);
				}
			}
			break;
		case GMsg.ONLINE_PAIDAN:
			mPresenter.showOrderListIng(false, null);
			ToastUtil.showToast(context, R.string.msg_paidan);
			break;
		case GMsg.ONLINE_CANCEL:
		case GMsg.ONLINE_KF_CANCEL:
			mPresenter.showOrderListIng(false, null);
			MessageDialog.onKfCancelDialog(context, msgs_data);
			break;
		case GMsg.ONLINE_GAIPAI:
		case GMsg.ONLINE_KF_GAIPAIL:
		case GMsg.ONLINE_SJ_GAIPAIL:
			mPresenter.showOrderListIng(false, null);
			MessageDialog.onGaipaiDialog(context, msgs_data);
			break;
		case GMsg.ONLINE_ONCAR:
			mPresenter.showOrderListIng(false, null);
			ToastUtil.showToast(context, R.string.msg_oncar);
			break;
		case GMsg.ONLINE_OFFCAR:// 下车，待支付
			mPresenter.showOrderListIng(false, null);
			MessageDialog.onOffCarDialog(context, msgs_data);
			break;
		case GMsg.ONLINE_FINISH:
			mPresenter.showOrderListIng(false, null);
			// ToastUtil.showToast(context, R.string.msg_finish);
			break;
		case GMsg.ONLINE_BUSY:
			MessageDialog.onBusyDialog(context, msgs_data);
			break;
		case GMsg.ONLINE_RELOGIN:
			MessageDialog.onReloginDialog(context);
			resetView(RESETVIEW.all);
			break;
		case GMsg.ONLINE_BG_ORDER:
			mPresenter.showOrderListIng(false, null);
			break;
		case GMsg.ONLINE_KF_CHANGE:
			ToastUtil.showToast(context, R.string.toast_change);
			MyOrderingTask.getInstance(context).setOnOrderingFinishListener(
					this);
			MyOrderTask.getInstance(context, MyOrderActivity.num_all2);
			break;
		case GMsg.ONLINE_KF_CHANGE_ORDER:
		case GMsg.ONLINE_KF_CHANGE_PRICE:
		case GMsg.ONLINE_KF_CHANGE_PRICE2:
			MessageDialog.onChangeDialog(context, type, msgs_data);
			MyOrderingTask.getInstance(context).setOnOrderingFinishListener(
					this);
			MyOrderTask.getInstance(context, MyOrderActivity.num_all2);
			break;
		case GMsg.ONLINE_ENTER_COUPON:
			RequestUtils.requestCouponCount(this);
			MessageDialog.onEnterCouponDialog(context, jb);
			break;
		case GMsg.OFFICAIL_AA:
			MessageDialog.onAADialog(context, msgs_data);
			break;
		case GMsg.ONLINE_SNTIMEOUT:
			MessageDialog.onSnTimeDialog(context, msgs_data);
			break;
		case GMsg.ONLINE_SNTOQIANGDAN:
			if (msgs_data != null && msgs_data.getOrder_id() != null
					&& !msgs_data.getOrder_id().equals("")) {
				MessageDialog.onSnQiangDanDialog(context,
						msgs_data.getOrder_id(), false, null);
			}
			break;
		}

	}

	@Override
	public void onNotify(int type, Object object) {
		switch (type) {
		case GMsg.ONLINE_ACTIVITY:
			MessageDialog.onActivityDialog(context, object, false);
			break;
		case GMsg.ONLINE_SNQIANGDAN:
			MessageDialog.onSnQiangDanDialog(context, (String) object, false,
					null);
			break;
		}

	}

	@Override
	public void onNotifyData(DATA_STATUS data_status, DATA_TYPE data_type,
			int status, Object object) {
		switch (data_type) {
		case COUPONCOUNT:
			if (IsDataFail.isDataFail(data_status)) {
				return;
			}
			CouponCount mCouponCount = (CouponCount) object;
			onCouponCount(mCouponCount);
			break;
		case BALANCE:
			break;
		case ACTIVITY:
			ActivityContent mActivityContent = (ActivityContent) object;
			onActivity(mActivityContent);
			break;
		case COUPONUSABLE:
			mPresenter.setCouponInfo(object);
			break;
		case USER:
			if (object != null) {
				User user = (User) object;
				Info info = user.info;
				mApplication.user_name = info.user_name;
				mApplication.user_phone = info.phone;
				mApplication.user_sex = info.sex;
				SharedPreUtil.putStringValue(this,
						SharedPreEncryptUtil.user_name, mApplication.user_name);
				SharedPreUtil.putStringValue(this,
						SharedPreEncryptUtil.user_sex, mApplication.user_sex);
				if (main != null) {
					if ((main.getName() == null || main.getName().equals(""))
							&& (main.getTel() == null || main.getTel().equals(
									""))) {
						main.setTel(mApplication.user_phone);
						main.setName(mApplication.user_name);

					}
				}
				initName();
			}
			break;
		case PRICE:
			onPrice(data_status, object);
			break;
		case PRICEALL:
			List<PriceAllDetail> detail = null;
			PriceAll mPriceAll = (PriceAll) object;
			if (mPriceAll != null)
				detail = mPriceAll.getList();
			if (detail != null && !detail.isEmpty()) {
				// 不能用这样，因为CONFIRM_CLICK 执行了一下优惠劵的显示跟隐藏，会导致很多问题
				// mHandler.sendEmptyMessage(CONFIRM_CLICK);
			
				if (MessageDialog.onSaveMoneyDialog(context, detail, this)) {
				}else{
					setEnabled(false);
				}
			}
			break;
		case METEREDFEE:
			onMeteredFee(object);
			break;
		case ORDERSUBMIT:
			if (object != null) {
				// TODO Auto-generated method stub
				OrderId mOrderId = (OrderId) object;
				LogUtils.e("", "提交成功,订单Id为：" + mOrderId.getOrderIdList());
				mPresenter.onWriteDB_ing(mOrderId.getOrderIdList());
				// mHandler.sendEmptyMessage(CONFIRM_NOCLICK);
			} else {
				ToastUtil.showToast(context,
						getResources().getString(R.string.no_network));
				mHandler.sendEmptyMessage(MainPresenter.CONFIRM_NOCLICK);
			}
			break;
		case LINE:
			isLoadFinish = true;
			if (IsDataFail.isDataFail(data_status)) {
				return;
			}
			if (!mPresenter.getIsLocation()) {
				setCityNotOpened();
			}
			break;
		case LOCATIONINFO:
			if (IsDataFail.isDataFail(data_status)) {
				return;
			}
			LocationInfo mLocationInfo = (LocationInfo) object;
			if (mLocationInfo != null) {
				switch(VersionUtils.getVersionType(context)){
				case bbx:
					tv_kftel.setText(Value.TEL_KF);
					break;
				case tianshang:
					tv_kftel.setText(Value.TEL_TSX);
					break;
				}
			}
			setTitle();
			break;
		case NEARBYDRIVERAR:
			if (IsDataFail.isDataFail(data_status)) {
				return;
			}
			//如果有目的地跟出发地，则不设置
			if (mPresenter.isNoStartNull()&&mPresenter.isNoEndNull()) {
				return;
			}
			NearByDriver mNearByDriver = (NearByDriver) object;
			ArrayList<DriverDetails> list = new ArrayList<NearByDriver.DriverDetails>();
			if (mNearByDriver != null)
				list = mNearByDriver.getList();
			try {
				clearMarker_Fujian();
				postDelayed_Near();
				if (list != null && !list.isEmpty()) {
					tv_nearcount.setText(list.size() + "");
					for (int i = 0; i < list.size(); i++) {
						Marker mMarker = null;
						LatLng ll = new LatLng(Double.parseDouble(list.get(i)
								.getLat()), Double.parseDouble(list.get(i)
								.getLng()));

						OverlayOptions oo = new MarkerOptions().position(ll)
								.icon(bdnear).zIndex(9).draggable(false);
						if (mBaiduMap != null)
							mMarker = (Marker) (mBaiduMap.addOverlay(oo));
						list_near_marker.add(mMarker);
					}
				} else {
					tv_nearcount.setText("0");
					if (list_near_marker != null)
						list_near_marker.clear();
				}
			} catch (Exception e) {
			}
			break;
		case ORDERDETAIL:
			// if(object!=null){
			// OrderDetails mOrderDetails=(OrderDetails)object;
			// onOrderDetailFinish(mOrderDetails);
			// }
			break;
		case CARTYPE:
			// if (IsDataFail.isDataFail(status)) {
			// return;
			// }
			loadCarTypeTime = DateFormat.getTime();
			mPresenter.dealCarType(status, object);
			break;
		case TUIJIAN:
			// 这边不做判断空处理，在onTuijian有相应的空出地图处理
			onTuijian((LeadStopsGetNearbys) object);
			break;
		case USABLESALE:
			if (object == null) {
				return;
			}
			UsableSale mUsableSale = (UsableSale) object;
			mPresenter.setUsableSale(mUsableSale);
			onUsableSale(mUsableSale);
			break;

		}

	}

	/**
	 * 优惠券信息
	 *
	 * @param mCouponCount
	 */
	@Override
	public void onCouponCount(CouponCount mCouponCount) {
		if (mCouponCount != null) {
			int count = mCouponCount.getCount();
			double totalsum = mCouponCount.getTotalsum();
			Wallect.couponSum=FormatUtil.onFormatDecimal(totalsum);
			Wallect.couponCount=count+"";
			if(count>0&&!Wallect.isClickShareCoupon){
				iv_wallet_new.setVisibility(View.VISIBLE);
				iv_new.setVisibility(View.VISIBLE);
			}else{
				iv_wallet_new.setVisibility(View.GONE);
				iv_new.setVisibility(View.GONE);
			}
		}
		if(Value.isNEW){

		}else{
			if (mCouponCount != null) {
				int count = mCouponCount.getCount();
				double totalsum = mCouponCount.getTotalsum();
				if (count == 0) {
					tv_coupon_count.setVisibility(View.INVISIBLE);
				} else {
					tv_coupon_count.setText(Html.fromHtml(String.format(
							context.getString(R.string.coupon_money),
							"<font color=\"#FF0000\">"
									+ FormatUtil.onFormatDecimal(totalsum)
									+ "</font>")));
					if (tv_coupon_count.getVisibility() != View.VISIBLE)
						tv_coupon_count.setVisibility(View.VISIBLE);
				}
			}
		}
	}

	@Override
	public void onActivity(final ActivityContent mActivityContent) {
		if (mActivityContent != null) {
			iv_right_sub.setVisibility(View.VISIBLE);
			ImageLoader imageLoader = new ImageLoader(context);
			if(mActivityContent.getList()!=null&&!mActivityContent.getList().isEmpty()){
				imageLoader.DisplayImage(mActivityContent.activity_lauch_icon,
						iv_right_sub, false);
				iv_right_sub.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						MessageDialog.onActivityDialog(context, mActivityContent,
								true);
					}
				});
			}else{
				iv_right_sub.setVisibility(View.INVISIBLE);
			}
		} else {
			iv_right_sub.setVisibility(View.INVISIBLE);
		}
		Publisher.getInstance().publish(GMsg.ONLINE_ACTIVITY, mActivityContent);
	}

	/** 车辆集合外布局 */
	private List<View> list_layout = new ArrayList<View>();
	private int layout_width = 0;
	private int layout_car_width;
	private int column = 3;// 列数
	/** 当前日租类型 */
	List<Integer> lits_bussiness;
	/** 车型加载时间，由于如果车型加载过快，马上显示车型，导致车型显示动画不正常 */
	long loadCarTypeTime = 0;

	@Override
	public void loadCarType(NewCarType mNewCarType,final boolean isThanksfee) {
		ScrollView scrollview = null;
		View view = null;
		LinearLayout layout_scroll2 = null;
		LinearLayout layout_scroll = null;
		MyHorizontalScrollView horizontalScrollView = null;
		ImageView iv_more_left = null;
		ImageView iv_more_right = null;
		RelativeLayout layout_cartype = null;
		switch(mPresenter.getViewId()){
		  case Value.VIEWID_SN:
			  scrollview=sn_scrollview;
			  view=view_sn;
			  layout_scroll2=sn_layout_scroll2;
			  layout_scroll=sn_layout_scroll;
			  horizontalScrollView=sn_horizontalScrollView;
			  iv_more_left=sn_iv_more_left;
			  iv_more_right=sn_iv_more_right;
			  layout_cartype=sn_layout_cartype;
			  break;
		  case Value.VIEWID_PC:
			  scrollview=cj_scrollview;
			  view=view_cj;
			  layout_scroll2=cj_layout_scroll2;
			  layout_scroll=cj_layout_scroll;
			  horizontalScrollView=cj_horizontalScrollView;
			  iv_more_left=cj_iv_more_left;
			  iv_more_right=cj_iv_more_right;
			  layout_cartype=cj_layout_cartype;
			  break;
		}
		if(scrollview==null||view==null||layout_scroll2==null||layout_scroll==null||horizontalScrollView==null
				||iv_more_left==null||iv_more_right==null||layout_cartype==null)return;
		
		if (!mPresenter.isBC()&&!mPresenter.isCity())
			return;
		if (mPresenter.getCarType() == null)
			return;
		int count = mPresenter.getCarType().getList().size();
		if (layout_width == 0) {
			try {
				layout_width = dm.widthPixels - scrollview.getPaddingLeft()
						- scrollview.getPaddingRight()
						- view.getPaddingLeft() - view.getPaddingRight();
			} catch (Exception e) {
			}
		}
		list_layout.clear();
		layout_scroll2.removeAllViews();
		layout_scroll.removeAllViews();
		LayoutInflater mInflater = context.getLayoutInflater();// 获取mInflater，用于加载布局
		for (int i = 0; i < count; i++) {
			final int position = i;
			View car_content = mInflater.inflate(R.layout.car_content, null);// 加载布局
			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.MATCH_PARENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			try {
				((TextView) (car_content.findViewById(R.id.tv_car)))
						.setText(mPresenter.getCarType().getList().get(i)
								.getList().get(0).car_name);
			} catch (Exception e) {
			}
			lp.gravity = Gravity.CENTER;
			list_layout.add(car_content);
			car_content.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					chooseCarType(position,isThanksfee);
				}
			});
			try {
				imageLoader.cut(
						this,
						(ImageView) (car_content.findViewById(R.id.iv_icon)),
						mPresenter.getCarType().getList().get(i).getList()
								.get(0).class_url, CUT.TOP);
			} catch (Exception e) {
			}
			if (count <=column) {
				lp.width = layout_width / count;
				layout_car_width=lp.width;
				car_content.setLayoutParams(lp);
				layout_scroll2.addView(car_content);
				horizontalScrollView.setScrollViewListener(null);
				iv_more_left.setVisibility(View.GONE);
				iv_more_right.setVisibility(View.GONE);
			} else {
				lp.width = layout_width / column;
				layout_car_width=lp.width;
				car_content.setLayoutParams(lp);
				layout_scroll.addView(car_content);
				horizontalScrollView.setScrollViewListener(this);
				iv_more_right.setVisibility(View.VISIBLE);
			}
		}
		/**layout_cartype2已layout_cartype是一样的，主要是final*/
		final RelativeLayout layout_cartype2=layout_cartype;
		long diff = DateFormat.getTime() - loadCarTypeTime;
		mHandler.postDelayed(new Runnable() {
			@Override
			public void run() {
				if (list_layout != null && !list_layout.isEmpty()) {
					list_layout.get(0).performClick();
					if (list_layout.size() > 1) {
						layout_cartype2.setVisibility(View.VISIBLE);
					} else {
						layout_cartype2.setVisibility(View.GONE);
					}
				}
				if (list_layout == null || list_layout.isEmpty()) {
					layout_cartype2.setVisibility(View.GONE);
				}
			}
		}, diff > 1500 ? 0 : (1500 - diff));
	}


	@Override
	public void setCar(String car_class_id,double thanks_fee) {
		List<NewData> list = mPresenter.getCarType().getList();
		for(int i=0;i<list.size();i++){
			if(list.get(i).class_id.equals(car_class_id)){
				main.setThanksfee((int)(thanks_fee/100));
				setThanks_fee();
				mPresenter.setStartThanksFee(thanks_fee);
				chooseCarType(i,false);
				return;
			}
		}
		
	}
	public void hideCarType(boolean isAll) {
		RelativeLayout layout_cartype=null;
		RelativeLayout layout_rent=null;
		switch(mPresenter.getViewId()){
		case Value.VIEWID_SN:
			layout_cartype=sn_layout_cartype;
			layout_rent=sn_layout_rent;
			break;
		case Value.VIEWID_PC:
			layout_cartype=cj_layout_cartype;
			layout_rent=cj_layout_rent;
			break;
		}
		if(layout_cartype==null||layout_rent==null)return;
		
		if(isAll){
			sn_layout_cartype.setVisibility(View.GONE);
			cj_layout_cartype.setVisibility(View.GONE);
			sn_layout_rent.setVisibility(View.GONE);
			cj_layout_rent.setVisibility(View.GONE);
		}else{
			layout_cartype.setVisibility(View.GONE);
			layout_rent.setVisibility(View.GONE);
		}
	}
	@Override
	public void onScrollChanged(int fangxiang) {
		ImageView iv_more_left = null;
		ImageView iv_more_right = null;
		switch(mPresenter.getViewId()){
		case Value.VIEWID_SN:
			iv_more_left=sn_iv_more_left;
			iv_more_right=sn_iv_more_right;
			break;
		case Value.VIEWID_PC:
			iv_more_left=cj_iv_more_left;
			iv_more_right=cj_iv_more_right;
			break;
		}
		if(iv_more_left==null||iv_more_right==null)return;
		
		final ImageView iv_more_left2 = iv_more_left;
		final ImageView iv_more_right2 = iv_more_right;
		
		try{
		switch(fangxiang){
		case MyHorizontalScrollView.LEFT:
			if(iv_more_left.getVisibility()!=View.GONE)
			iv_more_left.setVisibility(View.GONE);

			if(iv_more_right.getVisibility()!=View.VISIBLE)
			mHandler.postDelayed(new Runnable() {
				@Override
				public void run() {
						iv_more_right2.setVisibility(View.VISIBLE);
				}
			}, 200);
			break;
		case MyHorizontalScrollView.RIGHT:
			if(iv_more_right.getVisibility()!=View.GONE)
			iv_more_right.setVisibility(View.GONE);

			if(iv_more_left.getVisibility()!=View.VISIBLE)
			mHandler.postDelayed(new Runnable() {
				@Override
				public void run() {
					iv_more_left2.setVisibility(View.VISIBLE);
				}
			}, 200);
			break;
		case MyHorizontalScrollView.CENTER:
			break;
		}
		}catch(Exception e){}
	}
	@Override
	public void chooseCarType(int id,boolean isThanksfee) {
		MyHorizontalScrollView horizontalScrollView = null;
		switch(mPresenter.getViewId()){
		  case Value.VIEWID_SN:
			  horizontalScrollView=sn_horizontalScrollView;
			  break;
		  case Value.VIEWID_PC:
			  horizontalScrollView=cj_horizontalScrollView;
			  break;
		}
		
		setEnabled(false);
		if (!mPresenter.isBC()&&!mPresenter.isCity())
			return;
		if (id > list_layout.size() - 1)
			return;
		for (int i = 0; i < list_layout.size(); i++) {
			if (id == i) {
				mPresenter.setCarTypeId(id);
				try {
					imageLoader.cut(this, (ImageView) (list_layout.get(i)
							.findViewById(R.id.iv_icon)),
							mPresenter.getCarType().getList().get(i).getList()
									.get(0).class_url, CUT.BOTTOM);
				} catch (Exception e) {
				}
				// 显示日租类型
				if (mPresenter.getCarType().getList() != null
						&& !mPresenter.getCarType().getList().isEmpty()) {
					showRent(mPresenter.getCarType().getList().get(i).lits_bussiness,isThanksfee);
				}
				//移动试图
				if(horizontalScrollView!=null){
					horizontalScrollView.smoothScrollTo(layout_car_width*(i-1), 0);
				}
			} else {
				try {
					imageLoader.cut(this, (ImageView) (list_layout.get(i)
							.findViewById(R.id.iv_icon)),
							mPresenter.getCarType().getList().get(i).getList()
									.get(0).class_url, CUT.TOP);
				} catch (Exception e) {
				}
			}
		}
	}

	Integer[] list_rent = new Integer[] { 0, 1, 2 };
	Button[] list_sn_rent_btn = new Button[] { sn_btn_rent_1, sn_btn_rent_2,
			sn_btn_rent_3 };
	Button[] list_cj_rent_btn = new Button[] { cj_btn_rent_1, cj_btn_rent_2,
			cj_btn_rent_3 };

	@Override
	public void showRent(final List<Integer> lits_bussiness,final boolean isThanksfee) {
		Button[] list_rent_btn = null;
		RelativeLayout layout_cartype = null;
		RelativeLayout layout_rent=null;
		switch(mPresenter.getViewId()){
		   case Value.VIEWID_SN:
			   list_rent_btn=list_sn_rent_btn;
			   layout_cartype=sn_layout_cartype;
			   layout_rent=sn_layout_rent;
			   break;
		   case Value.VIEWID_PC:
			   list_rent_btn=list_cj_rent_btn;
			   layout_cartype=cj_layout_cartype;
			   layout_rent=cj_layout_rent;
			   break;
		}
		if(list_rent_btn==null||layout_cartype==null||layout_rent==null)return;
		
		if (!mPresenter.isBC()&&!mPresenter.isCity())
			return;
		if (lits_bussiness == null || lits_bussiness.isEmpty())
			return;
		this.lits_bussiness = lits_bussiness;
		for (int i = 0; i < list_rent.length; i++) {
			if (lits_bussiness.contains(list_rent[i])) {
				list_rent_btn[i].setVisibility(View.VISIBLE);
			} else {
				list_rent_btn[i].setVisibility(View.GONE);
			}
		}
		int delayMillis = 350;
		if(layout_cartype!=null&&layout_cartype.getVisibility()==View.VISIBLE){
			
		}
		// 如果只有一个单程的，则隐藏
		if (!lits_bussiness.isEmpty()&&!lits_bussiness.contains(CarType.BUSUNESS_TYPE_banri)
				&&!lits_bussiness.contains(CarType.BUSUNESS_TYPE_ri)) {
			if(layout_rent.getVisibility()==View.VISIBLE){
				delayMillis=700;
			}
			layout_rent.setVisibility(View.GONE);
		} else if (!lits_bussiness.isEmpty()) {
			if(layout_rent.getVisibility()==View.GONE){
				delayMillis=700;
			}
			layout_rent.setVisibility(View.VISIBLE);
		}else{
			if(layout_rent.getVisibility()==View.VISIBLE){
				delayMillis=700;
			}
			layout_rent.setVisibility(View.GONE);
		}
		//2种情况则延迟选中，先让动画走完
	    mHandler.postDelayed(new Runnable() {
			
			@Override
			public void run() {
				// 默认选中第一个
				chooseRent(lits_bussiness.get(0),isThanksfee);
			}
		}, delayMillis);
	}

	@Override
	public void chooseRent(int id,boolean isThanksfee) {
		Button[] list_rent_btn = null;
		switch(mPresenter.getViewId()){
		   case Value.VIEWID_SN:
			   list_rent_btn=list_sn_rent_btn;
			   break;
		   case Value.VIEWID_PC:
			   list_rent_btn=list_cj_rent_btn;
			   break;
		}
		if(list_rent_btn==null)return;
		
		setEnabled(false);
		if (!mPresenter.isBC()&&!mPresenter.isCity())
			return;
		for (int i = 0; i < list_rent_btn.length; i++) {
			if (i == id) {
				List<CarData> list_cardata = mPresenter.getCarType().getList()
				.get(mPresenter.getCarTypeId()).getList();
				CarData mCarData=null;
				for(int z=0;z<list_cardata.size();z++){
					CarData carData=list_cardata.get(z);
					if(carData.business_type==i){
						 mCarData=carData;
						 mPresenter.setRentId(z);
						 break;
					}
					
				}
				if(mCarData==null)return;
				main.setCarType(mPresenter.getViewId(), mCarData.car_type);
				main.setCarTypeName(mPresenter.getViewId(),mCarData.class_name);
				main.setSeatNum(mPresenter.getViewId(),mCarData.car_seats);
				main.setCarLevel(mPresenter.getViewId(),mCarData.car_level);
				main.setCalcType(mPresenter.getViewId(),mCarData.calc_type);
				main.setBusinessType(mPresenter.getViewId(), id);
				mPresenter.setComboPrice((long) mCarData.combo_price,(long) mCarData.night_combo_price);
				mPresenter.setCarClassId(mCarData.car_class_id);
				mPresenter.setPriceId(mCarData.price_id);
				if(mPresenter.isCity()){
				//重置感谢费
				   main.setThanksfee((int)(mCarData.getSchedulePrice(DateFormat.onDate_Long(main.getTime(mPresenter.isCity())))/100));
				   setThanks_fee();
				   mPresenter.setStartThanksFee(mCarData.getSchedulePrice(DateFormat.onDate_Long(main.getTime(mPresenter.isCity()))));
				}
				if(mCarData.getSchedulePrice(DateFormat.onDate_Long(main.getTime(mPresenter.isCity())))>0&&isThanksfee){
					showDragThanks();
				}
				//注意，由于包车没有返回calc_type字段，所以要自己设置， 不是单程的，那么就是公式计价
				if (mPresenter.isBC()&&main.getBusinessType(mPresenter.getViewId()) != CarType.BUSUNESS_TYPE_dan) {
					main.setCalcType(mPresenter.getViewId(),CarType.CALC_TYPE_jifei);
				}
				list_rent_btn[i].setBackgroundDrawable(getResources()
						.getDrawable(R.drawable.btn_rent));
				list_rent_btn[i].setTextColor(getResources().getColor(
						R.color.blue));
				// 起始点
				LatLng ll_start = new LatLng(main.getStartLatitude(mPresenter
						.isCity()), main.getStartLongitude(mPresenter.isCity()));
				// 终点
				LatLng ll_end = new LatLng(main.getEndLatitude(mPresenter
						.isCity()), main.getEndLongitude(mPresenter.isCity()));
				int distance = (int) (DistanceUtil
						.getDistance(ll_start, ll_end));
				// 包车的单程，或者市内打打表 ，走以前的旧接口
				if ((mPresenter.isBC()&&id == CarType.BUSUNESS_TYPE_dan)
						||(mPresenter.isCity()&&main.getCalcType(mPresenter.getViewId())==CarType.CALC_TYPE_dabiao)) {
					mPresenter.setPriceInfo(mCarData.car_class_id, false);
				} else {
					if(mPresenter.isBC()){
						RequestUtils.requesMeteredFee(context,mCarData,
								MyCarTypeTask.CARTYPE_BC, distance,
								mPresenter.getViewId(), main.getCjType());
					}else if(mPresenter.isCity()){
						RequestUtils.requesMeteredFee(context,mCarData,
								MyCarTypeTask.CARTYPE_SN, distance,
								mPresenter.getViewId(), main.getCjType());
					}
				}
			} else {
				list_rent_btn[i].setBackgroundColor(getResources().getColor(
						R.color.transparent));
				list_rent_btn[i].setTextColor(getResources().getColor(
						R.color.black));
			}
		}

	}

	@Override
	public void onPrice(DATA_STATUS STATUS, Object object) {
		// 处理顺风车
		if (mPresenter.isSF()) {
			String start_city = main.getStartCity();
			String end_city = main.getEndCity();
			// 出发地为漳州【或者】眉山【或者】出发地厦门目的地漳州，提示没有顺风车
			if (start_city.contains("漳州")
					|| start_city.contains("眉山")
					|| end_city.contains("漳州")) {
				showNoSfDailog();
				mHandler.postDelayed(new Runnable() {
					@Override
					public void run() {
						mPresenter.finishPriceInfo(false);
					}
				}, 500);
				return;
			}
		}
		if (STATUS == DATA_STATUS.SUCCESS) {
			if (object != null) {
				Price price = (Price) object;
				if (price.getDetail() != null) {
					if (price.getDetail().getLine_id() != null) {
						try{
						 mPresenter.setBaseDiscount(price.getPrice_detail().base_discount);
						}catch(Exception e){
							mPresenter.setBaseDiscount(100);
						}
						mPresenter.setPriceDetail(price.getPrice_detail());
						mPresenter.setLineId(price.getDetail().getLine_id());
						mPresenter.setPrice(price.getPrice());
						try{mPresenter.setBasePrice(price.price_detail.base_price);}catch(Exception e){};
						mPresenter.getCouponUsable(price.getPrice());
					} else {
						showPriceRemind(true, remind_line);
						mPresenter.finishPriceInfo(false);
						resetView(RESETVIEW.end);
						// 找不到该路线.跟-10一样的操作
						mHandler.sendEmptyMessage(MainPresenter.DIALOG_DISMISS);
						if (mPresenter.getViewId() != Value.VIEWID_SN) {
							final MyAlertDailog mydialog = new MyAlertDailog(
									context);
							mydialog.setTitle(context
									.getString(R.string.mydailog_title));
							mydialog.setContent(context
									.getString(R.string.price_no));
							mydialog.setSingle(context
									.getString(R.string.mydailog_know));
							mydialog.setOnClickSingleListener(new onClickSingleListener() {
								@Override
								public void onClickSingle() {
									mydialog.dismiss();
								}
							});
							mydialog.show();

						}

					}
				} else {
					mHandler.sendEmptyMessage(MainPresenter.DIALOG_DISMISS);
					if (mPresenter.getViewId() != Value.VIEWID_SN) {
						ToastUtil.showToast(context,
								getResources().getString(R.string.price_error));
						showPriceRemind(true, remind_price);
						mPresenter.finishPriceInfo(false);
					}
				}

			} else {
				mHandler.sendEmptyMessage(MainPresenter.DIALOG_DISMISS);
				if (mPresenter.getViewId() != Value.VIEWID_SN) {
					ToastUtil.showToast(context,
							getResources().getString(R.string.price_error));
					showPriceRemind(true, remind_price);
					mPresenter.finishPriceInfo(false);
				}
			}

		} else {
			mPresenter.finishPriceInfo(false);
			if (mPresenter.getViewId() != Value.VIEWID_SN) {
				if (MyPriceTask.status == -10) {
					Price.Note price_note = null;
					try {
						Price mPrice = (Price) new JsonBuild().getData(
								Price.class, MyPriceTask.msg);
						price_note = mPrice.getNote();
					} catch (Exception e) {
					}
					final Price.Note note = price_note;
					// 旧版本的没用该路线
					if (price_note == null) {
						resetView(RESETVIEW.end);
						final MyAlertDailog mydialog = new MyAlertDailog(
								context);
						mydialog.setTitle(context
								.getString(R.string.mydailog_title));
						mydialog.setContent(context
								.getString(R.string.price_no));
						mydialog.setSingle(context
								.getString(R.string.mydailog_know));
						showPriceRemind(true, remind_line);
						mydialog.setOnClickSingleListener(new onClickSingleListener() {
							@Override
							public void onClickSingle() {
								mydialog.dismiss();
							}
						});
						mydialog.show();
					} else {
						final MyAlertDailog mydialog = new MyAlertDailog(
								context);
						final MyLineNotDialog mylinedialog = new MyLineNotDialog(
								context);
						mydialog.setTitle(context
								.getString(R.string.mydailog_title));
						// ////////////////////
						// 切换到城际包车
						if (note.getPrice() != null
								&& !note.getPrice().equals("")) {
							mylinedialog.setContent(note.getMsg());
							int price = 0;
							try {
								price = Integer.parseInt(note.getPrice());
							} catch (Exception e) {
								price = (int) Double.parseDouble(note
										.getPrice());
							}
//							mylinedialog.setContent2(FormatUtil
//									.onFormatPrice(price));
							mylinedialog.setLeftButtonText(context
									.getString(R.string.mydailog_besides));
							mylinedialog.setRightButtonText(context
									.getString(R.string.text_charteredcar));
							mylinedialog
									.setOnLineClickLeftListener(new OnLineClickLeftListener() {
										@Override
										public void onLineClickLeft() {
											mylinedialog.dismiss();
										}
									});
							mylinedialog
									.setOnLineClickRightListener(new OnLineClickRightListener() {
										@Override
										public void onLineClickRight() {
											mylinedialog.dismiss();
											cj_label_bc.performClick();
										}
									});
							showPriceRemind(true, remind_line);
							mylinedialog.show();
						}
						// 切换到市内
						// else if (note.getIncity() != null
						// && note.getIncity().equals(Value.CITY_INCITY)
						// && lineid != null
						// && lineid.equals(note.getLine_id())) {
						//
						// mylinedialog.setContent(note.getMsg());
						// mylinedialog.setLeftButtonText(context
						// .getString(R.string.mydailog_besides));
						// mylinedialog
						// .setRightButtonText(getString(R.string.text_citycar));
						// mylinedialog
						// .setOnLineClickLeftListener(new
						// OnLineClickLeftListener() {
						// @Override
						// public void onLineClickLeft() {
						// mylinedialog.dismiss();
						// }
						// });
						// mylinedialog
						// .setOnLineClickRightListener(new
						// OnLineClickRightListener() {
						// @Override
						// public void onLineClickRight() {
						// mylinedialog.dismiss();
						// main.onCjToSn();
						// if (viewpager != null)
						// viewpager
						// .setCurrentItem(Value.VIEWID_SN);
						// }
						// });
						// mylinedialog.show();
						//
						// }
						// 呼叫客服或者旧版本的没用该路线
						else {
							String content = note.getMsg();
							// 切换到市内的，但是由于跟定位城市不同，则显示拨打客服
							if (note.getIncity() != null
									&& note.getIncity().equals(
											Value.CITY_INCITY)) {
								content = "您该次出行需拨打客服电话下单";
							}
							// 呼叫客服
							if (note.getLine_id() != null
									&& !note.getLine_id().equals("")) {
								mylinedialog.setContent(content);
								mylinedialog.setLeftButtonText(context
										.getString(R.string.mydailog_besides));
								mylinedialog
										.setRightButtonText(getString(R.string.mydailog_telkf));
								mylinedialog
										.setOnLineClickLeftListener(new OnLineClickLeftListener() {
											@Override
											public void onLineClickLeft() {
												mylinedialog.dismiss();
											}
										});
								mylinedialog
										.setOnLineClickRightListener(new OnLineClickRightListener() {
											@Override
											public void onLineClickRight() {
												mylinedialog.dismiss();
												Tel.onTel_KF(
														context,
														note.getLine_id(),
														(note.getIncity() != null && note
																.getIncity()
																.equals(Value.CITY_INCITY)));
											}
										});
								mylinedialog.show();
								showPriceRemind(true, remind_price);
							}
							// 旧版本的没用该路线
							else {
								resetView(RESETVIEW.end);
								mydialog.setTitle(context
										.getString(R.string.mydailog_title));
								mydialog.setContent(context
										.getString(R.string.price_no));
								mydialog.setSingle(context
										.getString(R.string.mydailog_know));
								mydialog.setOnClickSingleListener(new onClickSingleListener() {
									@Override
									public void onClickSingle() {
										mydialog.dismiss();
									}
								});
								mydialog.show();
								showPriceRemind(true, remind_line);
							}

						}
					}

				} else {
					ToastUtil.showToast(context,
							getResources().getString(R.string.price_error));
					showPriceRemind(true, remind_price);
				}
			}

		}
	}

	MeteredFee mMeteredFee;

	@Override
	public void onMeteredFee(Object object) {
		if (object == null) {
			mPresenter.finishPriceInfo(false);
			showPriceRemind(true, remind_price);
			return;
		}
		MeteredFee mMeteredFee = (MeteredFee) object;
		if (mMeteredFee != null) {
			this.mMeteredFee = mMeteredFee;
			try{
			mPresenter.setBaseDiscount(mMeteredFee.price_detail.base_discount);
			}catch(Exception e){}
			try{
			CarData mCarData = mPresenter.getCarType()
					.getList().get(mPresenter.getCarTypeId()).getList()
					.get(mPresenter.getRentId());
			mPresenter.setLineId(mCarData.line_id);
			}catch(Exception e){}
			mPresenter.setPrice((long)(mMeteredFee.total_price * mPresenter.getBaseDiscount()));
			mPresenter.setBasePrice(mMeteredFee.total_price);
			mPresenter.setPriceDetail(mMeteredFee.price_detail);
			mPresenter.getCouponUsable(mPresenter.getPrice());
		} else {
			mPresenter.finishPriceInfo(false);
			showPriceRemind(true, remind_price);
		}

	}

	/** 推荐上车点 */
	private List<Marker> list_tuijian_marker = new ArrayList<Marker>();
	private View tuijian_view;
	private TextView tuijian_info;
	BitmapDescriptor bdtuijian = BitmapDescriptorFactory
			.fromResource(R.drawable.icon_tuijian);

	@Override
	public void onTuijian(final LeadStopsGetNearbys mNearbys) {
		new AsyncTask<Void, Void, Void>() {
			@Override
			protected void onPreExecute() {
				// 清楚全部推荐上车覆盖物
				clearTuijian();
				if (tuijian_view == null || tuijian_info == null) {
					LayoutInflater inflater = LayoutInflater.from(context);
					tuijian_view = (View) inflater.inflate(
							R.layout.marker_tuijian, null);
					tuijian_info = (TextView) tuijian_view
							.findViewById(R.id.tv_info);
				}
				super.onPreExecute();
			}

			@Override
			protected Void doInBackground(Void... arg0) {
				if (mNearbys != null && mNearbys.points != null
						&& !mNearbys.points.isEmpty()) {
					Collections
							.sort(mNearbys.points, MainPresenter.mComparator);
					final List<PoiInfo> mPoiInfos = new ArrayList<PoiInfo>();
					for (GetNearbysPoints mGetPoint : mNearbys.points) {
						PoiInfo poiinfo = new PoiInfo();
						poiinfo.uid = "zzbbx1008611bbxzz";
						poiinfo.name = mGetPoint.da_name;
						poiinfo.address = mGetPoint.da_address;
						poiinfo.city = mPresenter.isCity() ? mApplication.loctionSnCity
								: mApplication.loctionCity;
						if (mGetPoint.da_point != null
								&& !mGetPoint.da_point.isEmpty()) {
							LatLng mLatLng = null;
							if (mGetPoint.da_point.size() > 1) {
								mLatLng = new LatLng(mGetPoint.da_point.get(1),
										mGetPoint.da_point.get(0));
							} else {
								mLatLng = new LatLng(0.0,
										mGetPoint.da_point.get(0));
							}
							poiinfo.location = mLatLng;
						}
						mPoiInfos.add(poiinfo);
					}

					// 互斥，强制移动。。默认设置第一项给出发地
					if (mNearbys.points.get(0).exclusive == 1) {
						try {
							main.isStartRecommend = true;
							main.setStartName(mPoiInfos.get(0).city + " "
									+ mNearbys.points.get(0).da_name);
							main.setStartAddress(mPoiInfos.get(0).address);
							main.setStartCity(mPoiInfos.get(0).city);
							main.setStartLatitude(mPoiInfos.get(0).location.latitude);
							main.setStartLongitude(mPoiInfos.get(0).location.longitude);
							mPresenter.shareView(SHAREVIEW_TYPE.share,
									SHAREVIEW_TYPE2.start);
						} catch (Exception e) {
						}
					} else {
						// P判断是否在附近10米内
						boolean fujin = false;
						// 互补的话判断最近的相距很近的时候，设置出发地
						for (PoiInfo mPoiInfo : mPoiInfos) {
							LatLng p1LL = new LatLng(
									main.getStartLatitude(mPresenter.isCity()),
									main.getStartLongitude(mPresenter.isCity()));
							LatLng p2LL = new LatLng(
									mPoiInfo.location.latitude,
									mPoiInfo.location.longitude);
							int miles = (int) DistanceUtil.getDistance(p1LL,
									p2LL);
							if (miles <= 20) {
								main.isStartRecommend = true;
								main.setStartName(mPoiInfo.city + " "
										+ mPoiInfo.name);
								main.setStartAddress(mPoiInfo.address);
								main.setStartCity(mPoiInfo.city);
								main.setStartLatitude(mPoiInfo.location.latitude);
								main.setStartLongitude(mPoiInfo.location.longitude);
								mPresenter.shareView(SHAREVIEW_TYPE.share,
										SHAREVIEW_TYPE2.start);
								fujin = true;
								break;
							}
						}
						if (!fujin) {
							main.isStartRecommend = false;
							mPresenter.shareView(SHAREVIEW_TYPE.share,
									SHAREVIEW_TYPE2.start);
						}
					}

					if (!mPoiInfos.isEmpty() && !mPresenter.isCity()) {
						// 循环添加覆盖物
						for (int i = 0; i < mPoiInfos.size(); i++) {
							try {
								final int position=i;
								context.runOnUiThread(new Runnable() {
									@Override
									public void run() {
										tuijian_info.setText(mPoiInfos.get(position).name);
									}
								});
								bdtuijian = BitmapDescriptorFactory
										.fromBitmap(ViewBitmap
												.getViewBitmap(tuijian_view));
								Marker mMarker = null;
								LatLng ll = new LatLng(
										mPoiInfos.get(i).location.latitude,
										mPoiInfos.get(i).location.longitude);

								OverlayOptions oo = new MarkerOptions()
										.position(ll)
										.title(mPoiInfos.get(i).name)
										.icon(bdtuijian).zIndex(9)
										.draggable(false);
								if (mBaiduMap != null)
									mMarker = (Marker) (mBaiduMap
											.addOverlay(oo));
								list_tuijian_marker.add(mMarker);
							} catch (Exception e) {
							}
						}
						mBaiduMap
								.setOnMarkerClickListener(new OnMarkerClickListener() {
									@Override
									public boolean onMarkerClick(Marker marker) {
										main.isStartRecommend = true;
										main.setStartName(main
												.getStartCity(mPresenter
														.isCity())
												+ " " + marker.getTitle());
										main.setStartAddress(marker.getTitle());
										main.setStartCity(main
												.getStartCity(mPresenter
														.isCity()));
										main.setStartLatitude(marker
												.getPosition().latitude);
										main.setStartLongitude(marker
												.getPosition().longitude);
										mPresenter.shareView(
												SHAREVIEW_TYPE.share,
												SHAREVIEW_TYPE2.start);
										return true;
									}
								});
					}
				} else {
					main.isStartRecommend = false;
					mPresenter.shareView(SHAREVIEW_TYPE.share,
							SHAREVIEW_TYPE2.start);
				}
				return null;
			}

			@Override
			protected void onPostExecute(Void result) {
				// TODO Auto-generated method stub
				super.onPostExecute(result);
			}

		}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
	}
	@Override
	public void onUsableSale(UsableSale mUsableSale) {
		TextView tv_usablesale = null;
		switch(mPresenter.getViewId()){
		case Value.VIEWID_SN:
			tv_usablesale=sn_tv_usablesale;
			break;
		case Value.VIEWID_PC:
			tv_usablesale=cj_tv_usablesale;
			break;
		case Value.VIEWID_KJ:
			tv_usablesale=kj_tv_usablesale;
			break;
		}
		if (mUsableSale != null) {
			int sale_type=mUsableSale.price_detail.sale_type;
			double sale_amount=mUsableSale.price_detail.sale_amount;
			String sale_id=mUsableSale.price_detail.sale_id;
			mPresenter.setSaleType(sale_type);
			mPresenter.setSaleAmount(sale_amount);
			mPresenter.setSaleId(sale_id);
			if(tv_usablesale==null)return;
			switch(sale_type){
			  case UsableSale.sale_type_no:
				  tv_usablesale.setVisibility(View.GONE);
				  break;
			  case UsableSale.sale_type_submit:
				  tv_usablesale.setText(Html.fromHtml(String.format(context.getString(R.string.sale_type_submit),"<font color=\"#ff0000\">"+FormatUtil.onFormatPrice(sale_amount)+"</font>")));
				  tv_usablesale.setVisibility(View.VISIBLE);
				  break;
			  case UsableSale.sale_type_online:
				  tv_usablesale.setText(Html.fromHtml(String.format(context.getString(R.string.sale_type_online),"<font color=\"#ff0000\">"+FormatUtil.onFormatPrice(sale_amount)+"</font>")));
				  tv_usablesale.setVisibility(View.VISIBLE);
				  break;
			}
		}else{
			tv_usablesale.setVisibility(View.GONE);
		}
	}
	@Override
	public void onOrderingFinish(ArrayList<MyOrderList> list) {
		mPresenter.showOrderListIng(true, list);

	}

	@Override
	public void onLocationResult(final BDLocation location) {
		if (mPresenter.getIsLocation() && location != null
				&& location.getCity() != null && location.getProvince() != null) {
			if (mApplication.isFirstClient2) {
				mApplication.isFirstClient2 = false;
				RequestUtils.requestActivity(this, location.getCity());
				RequestUtils.requestLocationInfo(context,
						location.getLongitude(), location.getLatitude(),
						location.getProvince(), location.getCity());
			}
			main = MainAttribute.getInstance();
			if (main.getStartName() == null || main.getStartName().equals("")) {
				mPresenter.setIsLocation(false);
				new AsyncTask<Void, Void, Void>() {
					String city;
					String district;
					String province;
					String address;

					@Override
					protected Void doInBackground(Void... arg0) {
						city = location.getCity();
						district = location.getDistrict();
						// 判断城际
						if (ToCity2.isDistrictExist(district,
								false)) {
							mApplication.loctionCity = district;
						} else {
							mApplication.loctionCity = city;
						}
						// 判断市内
						if (ToCity2
								.isDistrictExist(district, true)) {
							mApplication.loctionSnCity = district;
						} else {
							mApplication.loctionSnCity = city;
						}

						String str_name = mApplication.loctionCity
								+ " "
								+ location.getAddrStr().replace(
										getString(R.string.china)
												+ location.getProvince()
												+ location.getCity(), "");
						province = location.getProvince();
						address = location.getAddrStr();
						if (address.startsWith(getString(R.string.china))) {
							address = address.substring(2, address.length());
						}
						return null;
					}

					@Override
					protected void onPostExecute(Void result) {
						String cjcity = mApplication.loctionCity;
						String sncity = mApplication.loctionSnCity;
						main.setStartName(cjcity
								+ " "
								+ address.replace(
										province
												+ city
												+ ((district.equals(cjcity)) ? cjcity
														: ""), ""));
						main.setStartName(
								sncity
										+ " "
										+ address.replace(
												province
														+ city
														+ ((district
																.equals(sncity)) ? sncity
																: ""), ""),
								true);
						main.setStartCity(cjcity);
						main.setStartCity(sncity, true);
						main.setStartAddress(address);
						main.setStartAddress(address, true);
						main.setStartLongitude(location.getLongitude());
						main.setStartLongitude(location.getLongitude(), true);
						main.setStartLatitude(location.getLatitude());
						main.setStartLatitude(location.getLatitude(), true);
						MainAttribute.getInstance().isStartRecommend = false;
						MainAttribute.getInstance().isEndRecommend = false;
						onLocationDeal();
						locationtime=DateFormat.getTime();
						lat=location.getLatitude() + "";
						lng=location.getLongitude() + "";
						onLocationShowAddress(lat,lng);
						showCityType();
						if (isLoadFinish) {
							setCityNotOpened();
						}
//						mApplication.onStopLocation();
						super.onPostExecute(result);
					}

				}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
			}

		}
		//当定位被关闭的时候，我们只展示定位位置
		else if(!mPresenter.getIsLocation() ){
			showMyLocationView();
		}

	}

	@Override
	public void onLocationResult(final ReverseGeoCodeResult result) {
		if (mPresenter.getIsLocation() && result != null
				&& result.getAddressDetail().city != null
				&& result.getAddressDetail().province != null) {
			if (mApplication.isFirstClient2) {
				mApplication.isFirstClient2 = false;
				RequestUtils.requestActivity(this,
						result.getAddressDetail().city);
				RequestUtils.requestLocationInfo(context,
						result.getLocation().longitude,
						result.getLocation().latitude,
						result.getAddressDetail().province,
						result.getAddressDetail().city);
			}
			main = MainAttribute.getInstance();
				mPresenter.setIsLocation(false);
				new AsyncTask<Void, Void, Void>() {
					String city;
					String district;
					String province;
					String address;

					@Override
					protected Void doInBackground(Void... params) {
						city = result.getAddressDetail().city;
						district = result.getAddressDetail().district;
						// 判断城际
						if (ToCity2.isDistrictExist(district,
								false)) {
							mApplication.loctionCity = district;
						} else {
							mApplication.loctionCity = city;
						}
						// 判断市内
						if (ToCity2
								.isDistrictExist(district, true)) {
							mApplication.loctionSnCity = district;
						} else {
							mApplication.loctionSnCity = city;
						}
						province = result.getAddressDetail().province;
						address = result.getAddress();
						if (address.startsWith(getString(R.string.china))) {
							address = address.substring(2, address.length());
						}

						return null;
					}

					@Override
					protected void onPostExecute(Void mVoid) {
						String cjcity = mApplication.loctionCity;
						String sncity = mApplication.loctionSnCity;
						main.setStartName(cjcity
								+ " "
								+ address.replace(
										province
												+ city
												+ ((district.equals(cjcity)) ? cjcity
														: ""), ""));
						main.setStartName(
								sncity
										+ " "
										+ address.replace(
												province
														+ city
														+ ((district
																.equals(sncity)) ? sncity
																: ""), ""),
								true);
						main.setStartCity(cjcity);
						main.setStartCity(sncity, true);
						main.setStartAddress(address);
						main.setStartAddress(address, true);
						main.setStartLongitude(result.getLocation().longitude);
						main.setStartLongitude(result.getLocation().longitude,
								true);
						main.setStartLatitude(result.getLocation().latitude);
						main.setStartLatitude(result.getLocation().latitude,
								true);
						MainAttribute.getInstance().isStartRecommend = false;
						MainAttribute.getInstance().isEndRecommend = false;
						onLocationDeal();
						locationtime=DateFormat.getTime();
						lat=result.getLocation().latitude + "";
						lng=result.getLocation().longitude + "";
						onLocationShowAddress(lat,lng);
						showCityType();
						if (isLoadFinish) {
							setCityNotOpened();
						}
//						mApplication.onStopLocation();
						super.onPostExecute(mVoid);
					}

				}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

		}
		//当定位被关闭的时候，我们只展示定位位置
		else if(!mPresenter.getIsLocation() ){
			showMyLocationView();
		}
	}

	@Override
	public void onLocationFail(boolean isnet) {
		// TODO Auto-generated method stub

	}
	@Override
	public void onLocationDeal() {
		//如果定位在呼和浩特，则跳转到市内
		if(Value.isLocationHuhehaote(context)){
			if(!mPresenter.isCity()){
				if(gbSlideBar!=null)
				gbSlideBar.setCurrentItem(Value.VIEWID_SN);
			}
		}
		
	}
	String lat;
	String lng;
	@Override
	public void onLocationShowAddress(final String lat, final String lng) {
		if (mPresenter.getIsLocation()||showtime==0||lat==null||lng==null) {
			return;
		}
		long difftime=Math.abs(locationtime-showtime);
		long delayMillis;
		if(difftime>1000){
			delayMillis=0;
		}else{
			if(difftime>=0){
				delayMillis=1000-difftime;
			}else{
				delayMillis=1000;
			}
		}
		mHandler.postDelayed(new Runnable() {
			@Override
			public void run() {
				mPresenter.shareView(SHAREVIEW_TYPE.all,
						SHAREVIEW_TYPE2.start);
				mPresenter.shareView(SHAREVIEW_TYPE.all,
						SHAREVIEW_TYPE2.location);
				mHandler.postDelayed(new Runnable() {
					
					@Override
					public void run() {
						//获取推荐上车
						requesTuiJian(lat,lng);
					}
				}, 500);
				
			}
		}, delayMillis);
	}
	@Override
	public void onAddressPopViewState(boolean isOpen) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onContentFilling() {
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			if (mPresenter.isNoNullSn()) {
				mMeteredFee = null;
				mPresenter.setPriceInfo(null, true);
			} else {
				setEnabled(false);
			}
			break;
		case Value.VIEWID_KJ:// 小件快递
			if (mPresenter.isNoNullKj()) {
				mMeteredFee = null;
				mPresenter.setPriceInfo(null, true);
			} else {
				setEnabled(false);
			}
			break;
		case Value.VIEWID_PC:// 拼车出行
			if ((mPresenter.isBC()) ? mPresenter.isNoNullBc() : mPresenter
					.isNoNullPc()) {
				mMeteredFee = null;
				mPresenter.setPriceInfo(null, true);
			} else {
				setEnabled(false);
			}
			break;
		}

	}

	@Override
	public void onPageScrollStateChanged(int arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onPageScrolled(int arg0, float arg1, int arg2) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onPageSelected(int position) {
		// TODO Auto-generated method stub

	}

	@OnClick({R.id.layout_left ,R.id.confirm, R.id.personalDate, R.id.tv_myorder,
			R.id.layout_coupon, R.id.tv_message, R.id.tv_share, R.id.tv_set,
			R.id.tv_kftel, R.id.tv_prompt, R.id.iv_prompt_exit })
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.layout_left:
			if (!mApplication.isLogin()) {
				startActivityLogin();
				return;
			}
			if (mPresenter.isPriceInfo()) {
				resetView(RESETVIEW.all);
			} else {
				mMenuDrawer.openMenu();
			}
			break;
		case R.id.iv_locate:
			setCenterPoint();
			break;
		case R.id.lable_now:
			showSnOrKjTime(false, false);
			break;
		case R.id.lable_yuyue:
			showSnOrKjTime(true, false);
			break;
		case R.id.lable_pc:
			if (main.getCjType() == CjType.PC)
				return;
			main.setCjType(CjType.PC);
			//如果包车的车型是显示的，的延迟请求数据，先让车型隐藏
			int delayMillis=0;
			if ((cj_layout_cartype != null&&cj_layout_cartype.getVisibility()==View.VISIBLE)
					||(cj_layout_rent != null&&cj_layout_rent.getVisibility()==View.VISIBLE)){
				delayMillis=800;
			}
			showCjType();
			mHandler.postDelayed(new Runnable() {
				@Override
				public void run() {
					onContentFilling();
				}
			}, delayMillis);
			break;
		case R.id.lable_bc:
			if (main.getCjType() == CjType.BC)
				return;
			main.setCjType(CjType.BC);
			showCjType();
			onContentFilling();
			break;
		case R.id.lable_sf:
			if (main.getCjType() == CjType.SF)
				return;
			main.setCjType(CjType.SF);
			//如果包车的车型是显示的，的延迟请求数据，先让车型隐藏
			int delayMillis2=0;
			if (cj_layout_cartype != null&&cj_layout_cartype.getVisibility()==View.VISIBLE){
				delayMillis2=800;
			}
			showCjType();
			mHandler.postDelayed(new Runnable() {
				@Override
				public void run() {
					onContentFilling();
				}
			}, delayMillis2);
			break;
		case R.id.layout_time:
			showTimeSelector(v);
			break;
		case R.id.iv_content_open:
			showContactInfo();
			break;
		case R.id.tv_thanks_fee:
			switch (mPresenter.getViewId()) {
			case Value.VIEWID_SN:
				if(( (int)(mPresenter.getStartThanksFee()/100))>=Value.ThanksFeeMax){
					switch(VersionUtils.getVersionType(context)){
					case bbx:
						ToastUtil.showToast(context,context.getString(R.string.thanks_fee_max));
						break;
					case tianshang:
						ToastUtil.showToast(context,context.getString(R.string.thanks_fee_max2));
						break;
					}
					return ;
				}
				int thanks_fee_jine_id = 0;
				switch(VersionUtils.getVersionType(context)){
				case bbx:
					thanks_fee_jine_id=R.string.thanks_fee_jine;
					break;
				case tianshang:
					thanks_fee_jine_id=R.string.thanks_fee_jine2;
					break;
				}
				final CustomPicker pvCustom = DatePicker2.getInstance(this).showNum((int) (mPresenter.getStartThanksFee() / 100), Value.ThanksFeeMax);
				pvCustom.show();
				pvCustom.setCustomSelectListener(new CustomPicker.OnCustomSelectListener() {
					@Override
					public void onCustomSelect(int[] index) {
						int i=0;
						main.setThanksfee(Integer.parseInt(pvCustom.getData()[i].get(index[i])+""));
						setThanks_fee();
						pvCustom.dismiss();
					}
				});
//				DatePicker.getInstance(this).onShowPeople(v, (int)(mPresenter.getStartThanksFee()/100),
//						Value.ThanksFeeMax,
//						this.getString(thanks_fee_jine_id), null);
//				DatePicker.getInstance(this).setOnConfirmListener(
//						new OnConfirmListener() {
//							@Override
//							public void onConfirm(List<String> list,
//									WheelView people) {
//								main.setThanksfee(Integer.parseInt(list.get(people.getCurrentItem())));
//								setThanks_fee();
//							}
//						});
				break;
			case Value.VIEWID_PC:
				if (main.getCjType() == CjType.PC
						|| main.getCjType() == CjType.SF) {
					final CustomPicker pvCustom_num = DatePicker2.getInstance(this).showNum("",this.getString(R.string.num_rule),1, (Value.isChengDu()) ? 6 : 4);
					pvCustom_num.show();
					pvCustom_num.setCustomSelectListener(new CustomPicker.OnCustomSelectListener() {
						@Override
						public void onCustomSelect(int[] index) {
							int i = 0;
							main.setCount(Integer.parseInt(pvCustom_num.getData()[i].get(index[i]) + ""));
							tv_car_count.setText(Html.fromHtml(String
									.format(context
													.getString(R.string.num),
											"<font color=\"#ff0000\">"
													+ main.getCount()
													+ "</font>")));
							onContentFilling();
							pvCustom_num.dismiss();
						}
					});
//					DatePicker.getInstance(this).onShowPeople(v, 1,
//							(Value.isChengDu()) ? 6 : 4, null,
//							this.getString(R.string.num_rule));
//					DatePicker.getInstance(this).setOnConfirmListener(
//							new OnConfirmListener() {
//								@Override
//								public void onConfirm(List<String> list,
//										WheelView people) {
//									main.setCount(people.getCurrentItem() + 1);
//									tv_car_count.setText(Html.fromHtml(String
//											.format(context
//													.getString(R.string.num),
//													"<font color=\"#ff0000\">"
//															+ main.getCount()
//															+ "</font>")));
//									onContentFilling();
//								}
//							});
				}
				break;
			}

			break;
		case R.id.tv_coupon:
			if (mApplication.isLogin()) {
				if (layout_confirm.getVisibility() != View.VISIBLE) {
					if (mPresenter.getViewId() == Value.VIEWID_SN
							&& mPresenter.isNoNullSn()) {
						ToastUtil.showToast(context, "路线未开通，请联系客服");
					} else {
						ToastUtil.showToast(context, R.string.no_usbcoupon);
					}
				} 
				else if (mPresenter.getCouponsList() != null
						&& !mPresenter.getCouponsList().isEmpty()&&confirm.isEnabled()&&confirm.getVisibility()==View.VISIBLE) {
					list_available = mPresenter.getCouponsList();
					UseCouponMsg.mCouponUsableBulid=mPresenter.getCouponUsableBulid();
					onStartActivityForResult(new Intent(this,
							UseCouponActivity.class).putExtra(
							UseCouponMsg.coupon_id, mPresenter.getCouponId()),
							UseCouponMsg.requestCode);
				} else {
					ToastUtil.showToast(context, R.string.no_usbcoupon);
				}
			} else {
				startActivityLogin();
			}
			break;
		case R.id.layout_convert:
			if (!mApplication.isLogin()) {
				startActivityLogin();
				return;
			}
			main.onSwap();
			mPresenter.shareView(SHAREVIEW_TYPE.share, SHAREVIEW_TYPE2.start);
			mPresenter.shareView(SHAREVIEW_TYPE.share, SHAREVIEW_TYPE2.end);
			if (!main.isStartRecommend
					&& !TextUtils.isEmpty(main.getStartName())) {
				mPresenter.setRecommendForOrderTimeChanged();
			}
			break;
		case R.id.layout_start_address:
			if (!mApplication.isLogin()) {
				startActivityLogin();
				return;
			}
			if (!mPresenter.getIsLocation() || !mPresenter.isCity()) {
				Intent intent=new Intent(this, EditAddressActivity.class);
				Bundle bundle=new Bundle();
				bundle.putInt(AddressMsg.extra_editaddress,
						AddressMsg.ADDRESS_START_MAIN);
				bundle.putInt(AddressMsg.extra_viewid,
						mPresenter.getViewId());
				bundle.putBoolean(AddressMsg.extra_cityopend, true);
				bundle.putString(AddressMsg.extra_city, main.getStartCity(mPresenter.isCity()));
				intent.putExtras(bundle);
				onStartActivityForResult(intent,MainAttribute.REQUEST_CODE_START_ADDRESS);
			} else {
				ToastUtil.showToast(this, R.string.islocation_fail);
			}
			break;
		case R.id.layout_end_address:
			if (!mApplication.isLogin()) {
				startActivityLogin();
				return;
			}
			if (!mPresenter.getIsLocation() || !mPresenter.isCity()) {
				Intent intent=new Intent(this, EditAddressActivity.class);
				Bundle bundle=new Bundle();
				bundle.putInt(	AddressMsg.extra_editaddress,
						AddressMsg.ADDRESS_END_MAIN);
				bundle.putInt(AddressMsg.extra_viewid, mPresenter.getViewId());
				bundle.putString(AddressMsg.extra_city, main.getEndCity(mPresenter.isCity()));
				intent.putExtras(bundle);
				onStartActivityForResult(intent,
						MainAttribute.REQUEST_CODE_END_ADDRESS);
			} else {
				ToastUtil.showToast(this, R.string.islocation_fail);
			}
			break;
		case R.id.layout_end_parent:
			if (!mApplication.isLogin()) {
				startActivityLogin();
				return;
			}
			onStartActivityForResult(
					new Intent(this, ContactPersonActivity.class).putExtra(
							ContactPersonMsg.extra_contact_name,
							main.getName2()).putExtra(
							ContactPersonMsg.extra_contact_phone,
							main.getTel2()), MainAttribute.REQUEST_CODE_PERSON2);
			break;
		case R.id.tv_telephone:
			if (!mApplication.isLogin()) {
				startActivityLogin();
				return;
			}
			onStartActivityForResult(
					new Intent(this, ContactPersonActivity.class)
							.putExtra(ContactPersonMsg.extra_contact_name,
									main.getName()).putExtra(
									ContactPersonMsg.extra_contact_phone,
									main.getTel()),
					MainAttribute.REQUEST_CODE_PERSON);
			break;
		case R.id.tv_leave_message:
			onStartActivityForResult(
					new Intent(this, LeaveMessageActivity.class).putExtra(
							MainMsg.extra_message, MainMsg.MESSAGE_MAIN_PC),
					MainAttribute.REQUEST_CODE_MESSAGE);
			break;
		case R.id.confirm:
			if(!ClickFilter.filter())return;
			if (mApplication.isLogin()) {
				if(mPresenter.getBaseDiscount()>1){
					showDragAddFee();
				 }else{
					mPresenter.onOrderSubmit();
				}
			} else {
				startActivityLogin();
			}
			break;
		case R.id.tv_clause:
			onStartActivity(new Intent(this, ClauseActivity.class).putExtra(
					ClauseMsg.extra_clause, ClauseMsg.CLAUSE_KJ));
			break;
		case R.id.tv_prompt:
			if (!mApplication.isLogin()) {
				startActivityLogin();
				return;
			}
			// 跳转到订单详情界面,不能是支付状态
			if (mPresenter.getOrderListIng() != null
					&& mPresenter.getOrderListIng().size() == 1
					&& mPresenter.getOrderListIng().get(0).getOrder_status() != Value.ORDER_STATUS_OFFCAR) {
				Intent intent = new Intent(context, StartServiceActivity.class);
				intent.putExtra(OrderMsg.extra_type, 0);
				onStartActivity(intent);
			} else {
				onStartActivity(new Intent(MainActivity.this,
						MyOrderActivity.class));
			}
			break;
		case R.id.iv_prompt_exit:
			layout_prompt.setVisibility(View.GONE);
			showStartAndEnd();
			break;
		case R.id.iv_tel:
			onStartActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"
					+ xiadanTel)));
			break;
		case R.id.btn_rent_1:
			chooseRent(0,true);
			break;
		case R.id.btn_rent_2:
			chooseRent(1,true);
			break;
		case R.id.btn_rent_3:
			chooseRent(2,true);
			break;
		case R.id.layout_price:
			if ((mPresenter.isCity() && mMeteredFee == null) || getPriceRemid())
				return;
			showDragPrice();
			break;
		/** 以下都为抽屉 */
		case R.id.personalDate:// 个人信息
			onStartActivityForResult(
					new Intent(this, PersonalDataActivity.class),
					PersonalDataActivityMsg.requestCode);
			break;
		case R.id.tv_myorder:// 我的订单
			onStartActivity(new Intent(this, MyOrderActivity.class));
			break;
		case R.id.layout_coupon:// 优惠劵
			if(Value.isNEW){
			  onStartActivity(new Intent(this, WalletActivity.class));
			}else{
			  onStartActivity(new Intent(this, CouponActivity.class));
			}
			break;
		case R.id.tv_message:
			onStartActivity(new Intent(this, MessageActivity.class));
			break;
		case R.id.tv_share:// 推荐有奖
			onStartActivity(new Intent(this, RecommenActivity.class));
			break;
		case R.id.tv_set:// 设置
			onStartActivity(new Intent(this, SetActivity.class));
			break;
		case R.id.tv_kftel:
			
			switch(VersionUtils.getVersionType(context)){
			case bbx:
				// 用intent启动拨打电话
				onStartActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"
						+ Value.TEL_KF)));
				break;
			case tianshang:
				// 用intent启动拨打电话
				onStartActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"
						+ Value.TEL_TSX)));
				break;
			}
			break;
		}

	}

	public void setTitle() {
		String text = getString(R.string.app_name);
		if (Value.isLocationXinJiang(this)) {
			text = "天山行";
		}
		if (mPresenter.isPriceInfo()) {
			tv_title.setText(getString(R.string.confirm_no_price));
		} else {
			tv_title.setText(text);
		}

		tv_left_title.setText(text);
	}

	public Handler mHandler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case MainPresenter.DIALOG_SHOW:
				if (!isNoLoad) {
					if (mPresenter.getLoadView() != null
							&& !mPresenter.getLoadView().isShowing()) {
						context.runOnUiThread(new Runnable() {

							@Override
							public void run() {
								mPresenter.getLoadView().show();
							}
						});

					}
				}
				isNoLoad = false;
				break;
			case MainPresenter.DIALOG_DISMISS:
				if (mPresenter.getLoadView() != null) {
					mPresenter.getLoadView().onDismiss();
					mPresenter.setIsPrice(true);
				}
				break;
			case MainPresenter.CONFIRM_CLICK:
				setConfirm(false);
				break;
			case MainPresenter.CONFIRM_NOCLICK:
				setConfirm(true);
				break;
			}

		}
	};
	boolean isCjNotOpened = false;

	/** 获取城际是否开启线路 */
	public boolean IsCjNotOpened() {
		return isCjNotOpened;
	}

	MyCityNotOpenedDailog notopenedDialog;

	/**
	 * 如果是城际，则显示城市未开通,isShow true则显示弹窗，false则不弹窗 并返回布尔型true为有开通，false则没开通
	 */
	public void setCityNotOpened() {
//		if (notopenedDialog == null) {
//			notopenedDialog = new MyCityNotOpenedDailog(this);
//		}
//		new AsyncTask<Void, Void, Void>() {
//			boolean isSame = false;
//
//			@Override
//			protected Void doInBackground(Void... arg0) {
//				String location_city = mApplication.loctionCity;
//				if (location_city != null && !location_city.equals("")) {
//					List<Cities> list_city = db_line.readAllDB(false);
//					for (int i = 0; i < list_city.size(); i++) {
//						String in_city = list_city.get(i).getCn_Name();
//						if (ToCity.getCityName(in_city).equals(
//								ToCity.getCityName(location_city))
//								&& list_city.get(i).getIs_city()
//										.equals(Value.CITY_NOINCITY)) {
//							isSame = true;
//							break;
//						}
//					}
//				}
//				return null;
//			}
//
//			@Override
//			protected void onPostExecute(Void result) {
//				isCjNotOpened = isSame;
//				if (notopenedDialog != null && !notopenedDialog.isShowing()
//						&& !isSame) {
//					notopenedDialog.show();
//				}
//				new Handler().postDelayed(new Runnable() {
//
//					@Override
//					public void run() {
//						if (notopenedDialog != null) {
//							notopenedDialog.dismiss();
//						}
//					}
//				}, 3000);
//				super.onPostExecute(result);
//			}
//
//		}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
		switch (requestCode) {
		case MainActivity.requestCode:
			if (this.resultCode == resultCode) {
				resetView(RESETVIEW.all);
			}
			break;
		case MainAttribute.REQUEST_CODE_PERSON:// 电话
			if (data != null) {
				main.setTel(data.getStringExtra("telephone"));
				main.setName(data.getStringExtra("name"));
				if (main.getName() != null && main.getTel() != null
						&& !main.getName().equals("")
						&& !main.getTel().equals("")) {
				}
				mPresenter.shareView(SHAREVIEW_TYPE.all, SHAREVIEW_TYPE2.name);
			}
			break;
		case MainAttribute.REQUEST_CODE_PERSON2:
			if (data != null) {
				String name = data.getStringExtra("name");
				String tel = data.getStringExtra("telephone");
				if (name != null && tel != null && !name.equals("")
						&& !tel.equals("")) {
					main.setTel2(tel);
					main.setName2(name);
					mPresenter.shareView(SHAREVIEW_TYPE.kj,
							SHAREVIEW_TYPE2.name2);
				}
			}
			break;
		case MainAttribute.REQUEST_CODE_START_ADDRESS:// 出发地
			if (data != null) {
				main.setStartCity(
						data.getStringExtra(AddressMsg.extra_address_city),
						mPresenter.isCity());
				main.setStartAddress(
						data.getStringExtra(AddressMsg.extra_address_address),
						mPresenter.isCity());
				main.setStartLongitude(data.getDoubleExtra(
						AddressMsg.extra_address_longitude, 0), mPresenter
						.isCity());
				main.setStartLatitude(data.getDoubleExtra(
						AddressMsg.extra_address_latitude, 0), mPresenter
						.isCity());
				main.setStartName(
						data.getStringExtra(AddressMsg.extra_address_name),
						mPresenter.isCity());
				if (!main.getStartName(mPresenter.isCity()).equals("")) {
					if (mPresenter.isCity()) {
						mPresenter.shareView(SHAREVIEW_TYPE.sn,
								SHAREVIEW_TYPE2.start);
					} else {
						boolean isRecommend = data.getBooleanExtra(
								AddressMsg.extra_address_isRecommend, false);
						if (isRecommend) {
							main.isStartRecommend = true;
						} else {
							main.isStartRecommend = false;
						}
						mPresenter.shareView(SHAREVIEW_TYPE.share,
								SHAREVIEW_TYPE2.start);
					}
				}
			}
			break;
		case MainAttribute.REQUEST_CODE_END_ADDRESS:
			if (data != null) {
				main.setEndCity(
						data.getStringExtra(AddressMsg.extra_address_city),
						mPresenter.isCity());
				main.setEndAddress(
						data.getStringExtra(AddressMsg.extra_address_address),
						mPresenter.isCity());
				main.setEndLongitude(data.getDoubleExtra(
						AddressMsg.extra_address_longitude, 0), mPresenter
						.isCity());
				main.setEndLatitude(data.getDoubleExtra(
						AddressMsg.extra_address_latitude, 0), mPresenter
						.isCity());
				main.setEndName(
						data.getStringExtra(AddressMsg.extra_address_name),
						mPresenter.isCity());
				if (!main.getEndName(mPresenter.isCity()).equals("")) {
					if (mPresenter.isCity()) {
						mPresenter.shareView(SHAREVIEW_TYPE.sn,
								SHAREVIEW_TYPE2.end);
					} else {
						boolean isRecommend = data.getBooleanExtra(
								AddressMsg.extra_address_isRecommend, false);
						if (isRecommend) {
							main.isEndRecommend = true;
						} else {
							main.isEndRecommend = false;
						}
						mPresenter.shareView(SHAREVIEW_TYPE.share,
								SHAREVIEW_TYPE2.end);
					}
				}
			}
			break;
		case UseCouponMsg.requestCode:
			int coupon_id=0;
			if(data!=null){
			  coupon_id = data.getExtras().getInt(UseCouponMsg.coupon_id);
			}
			if(mPresenter.getUsableSale()!=null&&coupon_id!=0&&mPresenter.getSaleAmount()!=0){
				final MyAlertDailog dialog=new MyAlertDailog(this);
				dialog.setTitle(getString(R.string.mydailog_title));
				dialog.setContent("优惠券与立减折扣不能同时享用，是否选择优惠券？");
				dialog.setLeftButtonText("否");
				dialog.setRightButtonText("是");
				if (dialog != null && !dialog.isShowing()) {
					dialog.show();
				}
				dialog.setOnClickLeftListener(new onClickLeftListener() {	
					@Override
					public void onClickLeft() {
						dialog.dismiss();
					}
				});
				dialog.setOnClickRightListener(new onClickRightListener() {
					
					@Override
					public void onClickRight() {
						setCouponResult(data);
					}
				});
				return;
			}else{
				setCouponResult(data);
			}
			break;
		case MainAttribute.REQUEST_CODE_MESSAGE:
			if (data != null) {
				switch (mPresenter.getViewId()) {
				case Value.VIEWID_PC:
					main.setMessage_PC(data.getStringExtra("message"));
					tv_cj_message.setText(main.getMessage_PC());
					break;
				case Value.VIEWID_KJ:
					main.setMessage_KJ(data.getStringExtra("message"));
					tv_kj_message.setText(main.getMessage_KJ());
					break;
				}
			}
			break;
		case ThanksFeeMsg.code:
			try{
			setCar(data.getStringExtra(ThanksFeeMsg.car_class_id),data.getDoubleExtra(ThanksFeeMsg.thanksfee, 0));
			}catch(Exception e){}
			break;
		}
	}

	public void onStartActivity(Intent intent) {
		this.startActivity(intent);
		overridePendingTransition(R.anim.base_slide_right_in,
				R.anim.base_slide_remain);
		Publisher.getInstance().removeOb(this);
	}
	public void startActivity2(Intent intent) {
		this.startActivity(intent);
		overridePendingTransition(R.anim.fare_in,
				R.anim.fare_out);
		//不执行取消通知
//		Publisher.getInstance().removeOb(this);
	}

	public void onStartActivityForResult(Intent intent, int code) {
		context.startActivityForResult(intent, code);
		overridePendingTransition(R.anim.base_slide_right_in,
				R.anim.base_slide_remain);
		Publisher.getInstance().removeOb(this);
	}
	public void onStartActivityForResult2(Intent intent,int code) {
		context.startActivityForResult(intent, code);
		overridePendingTransition(R.anim.fare_in,
				R.anim.fare_out);
		//不执行取消通知
//		Publisher.getInstance().removeOb(this);
	}
	@Override
	public void startActivityLogin() {
		Intent intent = new Intent(this, LoginActivity.class);
		intent.putExtra(MainMsg.extra_login, MainMsg.INTENT_LOGIN);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		onStartActivity(intent);
	}

	private long mkeyTime;

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			if (dragLayout != null && dragLayout.isOpen()) {
				dragLayout.close();
				return true;
			}
			if (add_dragLayout != null && add_dragLayout.isOpen()) {
				add_dragLayout.close();
				return true;
			}
			if (thanks_dragLayout != null && thanks_dragLayout.isOpen()) {
				thanks_dragLayout.close();
				return true;
			}
			if ((DateFormat.getTime() - mkeyTime) > 2000) {
				mkeyTime = DateFormat.getTime();
				ToastUtil.showToast(context, R.string.agin_exit);
			} else {
				mApplication.exit();
				finish();
			}

			return true;

		}
		return false;
	}

	@Override
	public void finish() {
		SharedPreUtil.putStringValue(this, SharedPreEncryptUtil.order_type,
				mPresenter.getOrderType());
		WakeLockUtil.releaseWakeLock();
		if (mPresenter != null) {
			mPresenter.resetCenterPoint();
		}
		if (mApplication != null) {
			mApplication.loctionCity = "";
			mApplication.onStopLocation();

		}
		LoginService.SDKlogin = false;
		if (main != null) {
			main.onRestoreAttribute();
		}

		super.finish();
	}

	@Override
	protected void onStop() {
		super.onStop();
		MyOrderingTask.removeOnOrderingFinishListener(this);
		mHandler.removeCallbacks(position_near);
		if (!AppStarted.isRunningForeground(this)) {
			// 记录当前已经进入后台app 进入后台
			Value.isActive = false;
		}
	}

	@Override
	protected void onDestroy() {
		mHandler.removeCallbacks(position_near);
		SharedPreUtil.putStringValue(this, SharedPreEncryptUtil.order_type,
				mPresenter.getOrderType());
		CollecteAddressPop.removeOnPhotosPoPViewStateListener(this);
		Publisher.getInstance().removeOb(this);
		if (mApplication != null)
			mApplication.removeOnLocationResultListener(this);
		MessageDialog.clear();
		super.onDestroy();
	}

	/**
	 * ------------------------------以下全部为地图------------------------------------
	 * -------
	 */
	@Override
	public void requesTuiJian(String lat, String lng) {
		if (mPresenter.isPriceInfo())
			return;
		LogUtils.e("xxxx", "获取推荐上车点");
		RequestUtils.requesTuiJian(context, lat, lng, mPresenter.isCity());
	}

	@Override
	public void clearTuijian() {
		// 清楚全部推荐上车覆盖物
		if (list_tuijian_marker != null) {
			for (int i = 0; i < list_tuijian_marker.size(); i++) {
				list_tuijian_marker.get(i).remove();
			}
		}
		list_tuijian_marker.clear();

	}

	private GeoCoder mGeoCoder = null; // 地理编码
	private BaiduMap mBaiduMap;
	private MapStatusChangeListener mMapStatusChangeListener;
	private ReverseGeoCodeResult myposition;// 我的位置

	@Override
	public void initmap() {
		if (mMapView != null) {
			// 初始化搜索模块，注册事件监听
			mGeoCoder = GeoCoder.newInstance();
			mGeoCoder.setOnGetGeoCodeResultListener(this);
			mBaiduMap = mMapView.getMap();
			mMapStatusChangeListener = new MapStatusChangeListener();
			mBaiduMap.setOnMapStatusChangeListener(mMapStatusChangeListener);
			position_near = new MyPositionNearByDriver();
			icon_mapid.setPadding(0, 0, 0, (MeasureViewUtils.getMeasuredHeight(icon_mapid)/2)+DensityUtil.dip2px(context, 15));
		}
	}
	MyLocationData locData;
	@Override
	public void showMyLocationView() {
		try{
		if(mPresenter.isPriceInfo())return;
		 latitude = MyApplication.getInstance().mLocation
				.getLatitude();
		 longitude = MyApplication.getInstance().mLocation
				.getLongitude();
		mBaiduMap.setMyLocationEnabled(true);
		 locData = new MyLocationData.Builder()
		.accuracy(0)
		// 此处设置开发者获取到的方向信息，顺时针0-360
//		.direction(direction)
		.direction(210)
		.latitude(latitude)
		.longitude(longitude).build();
        mBaiduMap.setMyLocationData(locData);
        if( mBaiduMap.getLocationConfigeration().customMarker==null){
        	mBaiduMap
			.setMyLocationConfigeration(new MyLocationConfiguration(
					LocationMode.NORMAL, true,
					BitmapDescriptorFactory
							.fromResource(R.drawable.icon_mapid2)));
        }
       
		}catch(Exception e){}
	}
	@Override
	public void hideMyLocationView() {
		mBaiduMap.setMyLocationEnabled(false);
		mBaiduMap
		.setMyLocationConfigeration(new MyLocationConfiguration(
				LocationMode.NORMAL, true,null));
		
	}
	public class MapStatusChangeListener implements OnMapStatusChangeListener {
		public boolean isGeoCoder;
		/** 用于判断是否有执行过onMapStatusChange */
		public String status = "";
		public boolean isRemoveListener = false;
		LatLng old;

		public void setGeoCoder(boolean isGeoCoder) {
			this.isGeoCoder = isGeoCoder;
		}

		/** 短暂的移除监听，onMapStatusChangeFinish后又恢复原样 */
		public void setRemoveListener(boolean isRemoveListener) {
			this.isRemoveListener = isRemoveListener;
		}

		@Override
		public void onMapStatusChange(MapStatus mapStatus) {
			status = "change";
			if (isRemoveListener)
				return;
			if (old != null)
				if (!getIsMoveMap(mapStatus.target)) {
				} else {
					MypositionVisibility(View.GONE);
				}

		}

		@Override
		public void onMapStatusChangeFinish(final MapStatus mapStatus) {
			status = "finish";
			if (isRemoveListener) {
				old = mapStatus.target;
				if (mMapStatusChangeListener != null)
					mMapStatusChangeListener.setGeoCoder(true);
				isRemoveListener = false;
				return;
			}
			if (getIsGeoCoder(mapStatus.target)) {
				//延迟500毫秒才进行搜索
				Message msg=new Message();
				msg.what=MSG_GeoCoder;
				msg.obj=mapStatus;
				mMapHandler.sendMessageDelayed(msg, 500);
			} else {
				MypositionVisibility(View.VISIBLE);
			}
			if (mMapStatusChangeListener != null)
				mMapStatusChangeListener.setGeoCoder(true);
			old = mapStatus.target;
		}

		@Override
		public void onMapStatusChangeStart(MapStatus mapStatus) {
			mMapHandler.removeMessages(MSG_GeoCoder);
			status = "start";
			if (isRemoveListener)
				return;
			new Handler().postDelayed(new Runnable() {
				@Override
				public void run() {
					if (status != null && status.equals("start")
							&& mMapStatusChangeListener != null)
						mMapStatusChangeListener.setGeoCoder(true);
				}
			}, 200);
		}

		public boolean getIsGeoCoder(LatLng newll) {
			if (!getIsMoveMap(newll) || !isGeoCoder) {
				return false;
			}
			return true;
		}

		public boolean getIsMoveMap(LatLng newll) {
			int miles = (int) DistanceUtil.getDistance(old, newll);
			if (miles <= 3) {
				return false;
			}
			return true;
		}
		public final int MSG_GeoCoder=100;
		public Handler mMapHandler = new Handler() {
			public void handleMessage(android.os.Message msg) {
				switch (msg.what) {
				  case MSG_GeoCoder:
					  try{
					  MapStatus mapStatus=(MapStatus) msg.obj;
						onGeoCoder(mapStatus.target.latitude,
								mapStatus.target.longitude);
					  }catch(Exception e){}
					  break;
				}
			}
		};
	}

	@Override
	public void calculateMapCenterHeight() {
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			if (view_sn != null)
				height_content_sn = MeasureViewUtils.getMeasuredHeight(view_sn)
						+ MeasureViewUtils.getMeasuredHeight(layout_confirm);
			break;
		case Value.VIEWID_PC:
			if (mPresenter.isBC()) {
				height_content_bc = MeasureViewUtils.getMeasuredHeight(view_cj)
						+ MeasureViewUtils.getMeasuredHeight(layout_confirm);
			} else {
				height_content_pc = MeasureViewUtils.getMeasuredHeight(view_cj)
						+ MeasureViewUtils.getMeasuredHeight(layout_confirm);
			}
			break;
		case Value.VIEWID_KJ:
			height_content_kj = MeasureViewUtils.getMeasuredHeight(view_kj)
					+ MeasureViewUtils.getMeasuredHeight(layout_confirm);
			break;
		}
		calculateTopHeight();

	}

	@Override
	public void calculateTopHeight() {
		if (toptitle == 0) {
			int height_gbSlideBar = MeasureViewUtils
					.getMeasuredHeight(layout_gbslidebar);
			int height_title = MeasureViewUtils.getMeasuredHeight(title_bar);
			toptitle = height_gbSlideBar + height_title;
		}
	}

	@Override
	public void setMapCenterHeight() {
		if(!mPresenter.isShowStartEnd())return;
		int height_content = 0;
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			height_content = height_content_sn
					- MeasureViewUtils.getMeasuredHeight(view_sn_lable);
			break;
		case Value.VIEWID_PC:
			if (mPresenter.isBC()) {
				height_content = height_content_bc
						- MeasureViewUtils.getMeasuredHeight(view_cj_lable);
			} else {
				height_content = height_content_pc
						- MeasureViewUtils.getMeasuredHeight(view_cj_lable);
				;
			}
			break;
		case Value.VIEWID_KJ:
			height_content = height_content_kj
					- MeasureViewUtils.getMeasuredHeight(view_kj_lable);
			;
			break;
		}
		int prompy_height = 0;
		if (layout_prompt.getVisibility() == View.VISIBLE) {
			prompy_height = MeasureViewUtils.getMeasuredHeight(layout_prompt);
		}
		if (height_content != 0) {
			int top = toptitle + prompy_height;
			mapheight_center = ((dm.heightPixels - height_content - top) / 2)
					+ top;
			mapBoundsHeight=(dm.heightPixels - height_content - top);
		}
	}
	@Override
	public void clearMapCenterHeight() {
		mapwidth_center = dm.widthPixels / 2;
		mapBoundsWidth= dm.widthPixels;
		mapheight_center = (dm.heightPixels-StatusBar.getStatusHeight(context)) / 2;
		mapBoundsHeight=(dm.heightPixels-StatusBar.getStatusHeight(context));
	}
	@Override
	public int getIsViewContentHeight() {
		int height_content = 0;
		switch (mPresenter.getViewId()) {
		case Value.VIEWID_SN:
			height_content = height_content_sn;
			break;
		case Value.VIEWID_PC:
			if (mPresenter.isBC()) {
				height_content = height_content_bc;
			} else {
				height_content = height_content_pc;
			}
			break;
		case Value.VIEWID_KJ:
			height_content = height_content_kj;
			break;
		}
		return height_content;
	}

	@Override
	public void setCenterPoint(double lat, double lng, final float zoom) {
		LatLng cenpt = new LatLng(lat, lng);
		setMapStatus(cenpt, zoom);
	}

	@Override
	public void setCenterPoint(LatLng centll, final float zoom) {
		setCenterPoint(centll.latitude, centll.longitude, zoom);

	}

	@Override
	public void setCenterPoint() {
		if (mPresenter.getCenterPoint() != null) {
			setCenterPoint(mPresenter.getCenterPoint().latitude,
					mPresenter.getCenterPoint().longitude, mPresenter.getZoom());
		} else {
			setCenterPoint(mApplication.latitude, mApplication.longitude,
					mPresenter.getZoom());

		}
	}

	@Override
	public void setStartPoint(boolean isRemoveListener) {
		if (mPresenter.getCenterPoint() != null) {
			setCenterPoint(mPresenter.getCenterPoint().latitude,
					mPresenter.getCenterPoint().longitude, mPresenter.getZoom());
		} else {
			if (!mPresenter.isNoEndNull()) {
				LatLng ptCenter = new LatLng(main.getStartLatitude(mPresenter
						.isCity()), main.getStartLongitude(mPresenter.isCity()));
				if (mMapStatusChangeListener != null && isRemoveListener)
					mMapStatusChangeListener.setRemoveListener(true);
				setCenterPoint(ptCenter, mPresenter.getZoom());
				postDelayed_Near();
				if (!mPresenter.isCity()) {
					// 获取推荐上车点
					requesTuiJian(main.getStartLatitude() + "",
							main.getStartLongitude() + "");
				}
			}
		}
	}

	/**
	 * 设置地图的位置 isstart 是判断是否要监控地图位置，并设置出发地
	 */
	public void setMapStatus(LatLng ll, final float zoom) {
		// 经纬度为空，则显示定位位置，如果再为空则失败的位置
		if (ll.latitude == 0 || ll.longitude == 0) {
			ll = new LatLng(mApplication.latitude, mApplication.longitude);
			if (ll.latitude == 0 || ll.longitude == 0) {
				ll = mApplication.ll_fail;
			}
			// 定位是在，则重新定位
			if (mMapStatusChangeListener != null)
				mMapStatusChangeListener.setGeoCoder(true);
		}
		Point p = new Point(mapwidth_center, mapheight_center);
		Log.e("xxxx", ll+"...........");
		final LatLng mLatLng = ll;
		MapStatus.Builder builder = new MapStatus.Builder();
		builder.target(mLatLng).targetScreen(p);
		// 如果小于0，则代表不设置缩放级别
		if (zoom >= 0) {
			builder.zoom(zoom);
		}
		final MapStatus mMapStatus = builder.build();
		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				MapStatusUpdate u = MapStatusUpdateFactory
						.newMapStatus(mMapStatus);
				// 改变地图状态
				if (mBaiduMap != null)
					try {
						position_near.setLatLng(mLatLng);
						mBaiduMap.animateMapStatus(u);
						// if(!mPresenter.isPriceInfo())
						// mHandler.postDelayed(new Runnable() {
						// @Override
						// public void run() {
						// mBaiduMap
						// .setOnMapStatusChangeListener(mMapStatusChangeListener);
						// }
						// }, 500);
					} catch (Exception e) {
					}
			}
		}, 0);
	}

	public void setGeoCoder(boolean isGeoCoder) {
		if (mMapStatusChangeListener != null) {
			if (isGeoCoder) {
				mMapStatusChangeListener.setGeoCoder(true);
			} else {
				mMapStatusChangeListener.setGeoCoder(false);
			}
		}
	}

	/**
	 * 设置地图大小
	 */
	public void setMapZoom(final int zoom) {
		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(zoom);
				if (mBaiduMap != null)
					try {
						mBaiduMap.animateMapStatus(u);
					} catch (Exception e) {
					}
			}
		}, 300);
	}

	@Override
	public void onGeoCoder(double latitude, double longitude) {
		// 如果价格信息展开，则不执行搜索
		if (mPresenter.isPriceInfo()) {
			return;
		}
		LogUtils.e("xxxx", "执行搜索");
		LatLng ptCenter = new LatLng(latitude, longitude);
		// 反Geo搜索
		mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption().location(ptCenter));
	}

	@Override
	public void onGetGeoCodeResult(GeoCodeResult arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {
		if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR
				|| result.getPoiList() == null) {
			return;
		}
		myposition = result;
		final Animation anim = AnimationUtils.loadAnimation(this, R.anim.mapid);
		icon_mapid.startAnimation(anim);
		anim.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationStart(Animation arg0) {
			}

			@Override
			public void onAnimationRepeat(Animation arg0) {
			}

			@Override
			public void onAnimationEnd(Animation arg0) {
				Animation anim = AnimationUtils.loadAnimation(
						MainActivity.this, R.anim.dialog_in);
				MypositionVisibility(View.VISIBLE);
				layout_myposition.startAnimation(anim);
				new AsyncTask<Void, Void, Void>() {
					String city;
					String name = "";

					@Override
					protected Void doInBackground(Void... params) {
						if (myposition != null) {
							position_near.setLatLng(myposition.getLocation());
							postDelayed_Near();
							city = myposition.getAddressDetail().district
									.trim();
							// 判断是二级城市
							if (ToCity2.isDistrictExist(city,
									mPresenter.getViewId() == Value.VIEWID_SN)) {
								city = myposition.getAddressDetail().district
										.trim();
								name = city + " " + myposition.getAddress();
								name = name.replace(
										myposition.getAddressDetail().province
												+ myposition.getAddressDetail().city
												+ city, "");
							} else {
								city = myposition.getAddressDetail().city
										.trim();
								name = city + " " + myposition.getAddress();
								name = name.replace(
										myposition.getAddressDetail().province
												+ city, "");
							}
						}
						return null;
					}

					@Override
					protected void onPostExecute(Void result) {
						String location_city = mPresenter.isCity() ? mApplication.loctionSnCity
								: mApplication.loctionCity;
						if (ToCity2.getCityName(city).equals(
								ToCity2.getCityName(mPresenter.getOldCity()))
								||ToCity2.getCityName(city).equals(
										ToCity2.getCityName(location_city))) {
							if (myposition != null) {
								main.setStartCity(city, mPresenter.isCity());
								main.setStartAddress(myposition.getAddress(),
										mPresenter.isCity());
								main.setStartLongitude(
										myposition.getLocation().longitude,
										mPresenter.isCity());
								main.setStartLatitude(
										myposition.getLocation().latitude,
										mPresenter.isCity());
								main.setStartName(name, mPresenter.isCity());
								if (!main.getStartName(mPresenter.isCity())
										.equals("")) {
									if (mPresenter.isCity()) {
										mPresenter.shareView(SHAREVIEW_TYPE.sn,
												SHAREVIEW_TYPE2.start);
									} else {
										// 获取推荐上车点
										requesTuiJian(
												myposition.getLocation().latitude
														+ "",
												myposition.getLocation().longitude
														+ "");
									}
								}
							}
						} else {
							layout_nearcount.setVisibility(View.GONE);
							tv_myposition.setText(String.format(
									getString(R.string.remove_position),
									mPresenter.getOldCity()));
							mPresenter.setAnchorText(tv_myposition.getText().toString());
							// main.setStartCity("", mPresenter.isCity());
							main.setStartAddress("", mPresenter.isCity());
							main.setStartLongitude(myposition.getLocation().longitude, mPresenter.isCity());
							main.setStartLatitude(myposition.getLocation().latitude, mPresenter.isCity());
							main.setStartName("", mPresenter.isCity());
							if (mPresenter.isCity()) {
								mPresenter.shareView(SHAREVIEW_TYPE.sn,
										SHAREVIEW_TYPE2.start);
							} else {
								mPresenter.shareView(SHAREVIEW_TYPE.share,
										SHAREVIEW_TYPE2.start);
							}
						}
						super.onPostExecute(result);
					}

				}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

			}
		});
	}

	/** 起始点覆盖物 */
	private Marker mMarker_start;
	/** 终点覆盖物 */
	private Marker mMarker_end;

	@Override
	public void clearMarker(boolean isAll) {
		if (mMarker_start != null) {
			mMarker_start.remove();
		}
		if (mMarker_end != null) {
			mMarker_end.remove();
		}
		if (isAll || mPresenter.isCity()) {
			clearTuijian();
		}
		clearMarker_Fujian();
		try {
			MypositionVisibility(View.VISIBLE);
			icon_mapid.setVisibility(View.VISIBLE);
			clearMapCenterHeight();
			showMyLocationView();
			mBaiduMap.setOnMapStatusChangeListener(mMapStatusChangeListener);
		} catch (Exception e) {
		}
	
	}
	@Override
	public void clearMarker_Fujian() {
		if (list_near_marker != null) {
			for (int i = 0; i < list_near_marker.size(); i++) {
				list_near_marker.get(i).remove();
			}
			list_near_marker.clear();
		}
	}
	BitmapDescriptor bd_start = BitmapDescriptorFactory
			.fromResource(R.drawable.icon_map_start);
	BitmapDescriptor bd_end = BitmapDescriptorFactory
			.fromResource(R.drawable.icon_map_end);
	@Override
	public void showStartAndEnd() {
		if(!mPresenter.isShowStartEnd())return;
		list_near_marker.clear();
		clearMarker(false);
		calculateMapCenterHeight();
		setMapCenterHeight();
		clearTuijian();
		clearMarker_Fujian();
		mBaiduMap.clear();
		mHandler.removeCallbacks(position_near);

		if(main.getStartLatitude(mPresenter.isCity())!=0&&main.getStartLongitude(mPresenter.isCity())!=0
				&&main.getEndLatitude(mPresenter.isCity())!=0&&main.getEndLongitude(mPresenter.isCity())!=0){
			// 起始点
			LatLng ll_start = new LatLng(
					main.getStartLatitude(mPresenter.isCity()),
					main.getStartLongitude(mPresenter.isCity()));
			OverlayOptions oo_start = new MarkerOptions().position(ll_start)
					.icon(bd_start).draggable(false);
			// 终点
			LatLng ll_end = new LatLng(main.getEndLatitude(mPresenter.isCity()),
					main.getEndLongitude(mPresenter.isCity()));
			OverlayOptions oo_end = new MarkerOptions().position(ll_end).icon(bd_end)
					.zIndex(9).draggable(false);
			ZoomUtils.setZoom(context,mBaiduMap, mapwidth_center, mapheight_center, mapBoundsWidth, mapBoundsHeight, ll_start, ll_end);

		if (mBaiduMap != null) {
			if (mMarker_start != null)
				mMarker_start.remove();
			mMarker_start = (Marker) (mBaiduMap.addOverlay(oo_start));
		}
		if (mBaiduMap != null) {
			if (mMarker_end != null)
				mMarker_end.remove();
			mMarker_end = (Marker) (mBaiduMap.addOverlay(oo_end));
		 }
			final LatLng centll = new LatLng(
					(ll_start.latitude + ll_end.latitude) / 2,
					(ll_start.longitude + ll_end.longitude) / 2);
			mHandler.postDelayed(new Runnable() {
				@Override
				public void run() {
					mPresenter.setCenterPoint(centll, mBaiduMap.getMapStatus().zoom);
				}
			},500);

		}
		MypositionVisibility(View.GONE);
		icon_mapid.setVisibility(View.GONE);
		hideMyLocationView();
		if (mBaiduMap != null)
			mBaiduMap.setOnMapStatusChangeListener(null);

	}

	/** 附近的司机覆盖物 */
	private List<Marker> list_near_marker = new ArrayList<Marker>();
	private MyPositionNearByDriver position_near;
	BitmapDescriptor bdnear = BitmapDescriptorFactory
			.fromResource(R.drawable.icon_carx);

	/** 附近的司机 */
	public class MyPositionNearByDriver implements Runnable {
		private LatLng ll_start;

		public void setLatLng(LatLng ll_star) {
			this.ll_start = ll_star;
		}

		@Override
		public void run() {
			if (mPresenter == null || mPresenter.getLineId() == null
					|| ll_start == null || !mPresenter.isCity()
					|| (Citytype != null && Citytype != CITYTYPE.APP)
					||mPresenter.getAnchorIsYichu())
				return;
			/** 获取附近的司机 */
			RequestUtils.requestNearByDriver(context, "",
					mPresenter.getLineId(), ll_start.longitude,
					ll_start.latitude, 1000, false);
		}
	}

	@Override
	public void postDelayed_Near() {
		mHandler.removeCallbacks(position_near);
		mHandler.postDelayed(position_near, 1000 * 5);

	}

	@Override
	public void MypositionVisibility(int VISIBLE) {
		layout_myposition.setVisibility(VISIBLE);
		if (VISIBLE == View.VISIBLE) {
			// 有出发地跟目的地的时候，则要隐藏
			if (mPresenter.isNoStartNull() && mPresenter.isNoEndNull()) {
				layout_myposition.setVisibility(View.GONE);
			} else {
				// 出发地为空的时候
				if (!mPresenter.isNoStartNull()) {
					if (mPresenter.getAnchorIsYichu()) {
						layout_myposition.setVisibility(View.VISIBLE);
					} else {
						layout_myposition.setVisibility(View.GONE);
					}
					clearMarker_Fujian();
				}
			}
		}

	}

	/**
	 * 监控出发地
	 * */
	public class startTextWatcher implements TextWatcher {

		@Override
		public void afterTextChanged(Editable arg0) {
			// TODO Auto-generated method stub

		}

		@Override
		public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
				int arg3) {
			// TODO Auto-generated method stub

		}

		@Override
		public void onTextChanged(CharSequence arg0, int arg1, int arg2,
				int arg3) {
			// 有出发地没有目的地
			if (mPresenter.isNoStartNull() && !mPresenter.isNoEndNull()) {
				LatLng ptCenter = new LatLng(main.getStartLatitude(mPresenter
						.isCity()), main.getStartLongitude(mPresenter.isCity()));
				setGeoCoder(false);
				setMapStatus(ptCenter, -1);
				MypositionVisibility(View.VISIBLE);
				setAnchor();
			}
		}

	}
	
    private float lastX;  
   /**当传感器的精度变化时会调用*/
	@Override
	public void onAccuracyChanged(Sensor arg0, int arg1) {
		// TODO Auto-generated method stub
		
	}
	  /**当传感器的值发生变化时，例如磁阻传感器的方向改变时会调用*/
	@Override
	public void onSensorChanged(SensorEvent sensorEvent) {
		//方向感应检测
		 if(sensorEvent.sensor.getType()==Sensor.TYPE_ORIENTATION)  
	        {  
	            float x=sensorEvent.values[SensorManager.DATA_X];  
	            if(Math.abs(x-lastX)>1.0)  
	            {  
	             direction=x;
	       		showMyLocationView();
	            }  
	            lastX=x;  
	  
	        } 
	
	}
}
